How to Use the jQuery post() Method

jQuery's post() method is a convenience function that can be used for making a simple POST request. The following six steps show how to get started using this method.

  1. Download the jQuery library from or find a link to the latest version of jQuery by going to
  2. Create an HTML document that includes the jQuery library.
    <!DOCTYPE html>
    <html lang="en">
        <meta charset="UTF-8">
        <script src=""></script>
  3. Inside a script element in your HTML document, write jQuery's ready() function, which will wait until the selected object (the HTML document in this case) is ready before executing the code passed into it.
        $(document).ready(function() {
  4. Write the post() method inside the body of the function passed into the ready() method. The only required argument is the first one, which is the URL to make the request to.
        $(document).ready(function() {
  5. After the URL, pass any of the following arguments to post():
    • data - The data to be sent to the server. This can either be an object, like {foo:'bar',baz:'bim' }, or a query string, such as foo=bar&baz=bim.
    • success - A callback function to run if the request succeeds. The function receives the response data (converted to a JavaScript object if the data type was JSON), as well as the text status of the request and the raw request object.
    • dataType - The type of data you expect back from the server.
  6. Write a success callback function, which will receive the result of the request.
    $.post('users','userID=8', function(user) {
        $('<h1/>').text('Welcome ' + user.firstName).appendTo('body');
    Result of Running the post() Demo Script
Author: Chris Minnick

Chris Minnick, the co-founder of WatzThis?, has overseen the development of hundreds of web and mobile projects for customers from small businesses to some of the world’s largest companies. A prolific writer, Chris has authored and co-authored books and articles on a wide range of Internet-related topics including HTML, CSS, mobile apps, e-commerce, e-business, Web design, XML, and application servers. His published books include Adventures in Coding, JavaScript For Kids For Dummies, Writing Computer Code, Coding with JavaScript For Dummies, Beginning HTML5 and CSS3 For Dummies, Webkit For Dummies, CIW E-Commerce Designer Certification Bible, and XHTML.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. Check out our complete course catalog.