jQuery post() example

jQuery post() function is used to load data from the server using an HTTP POST request.


Load data from the server using an HTTP POST request.


jQuery.post( url [, data ] [, success ] [, dataType ] )
  • url - A string containing the URL to which the request is sent.
  • data - A plain object or string that is sent to the server with the request.
  • success - A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.
  • dataType - The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).


The following example uses the $.post() method to send some data along with the request:
<!DOCTYPE html>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
        $(document).ready(function() {
            $("button").click(function() {
                $.post("https://www.w3schools.com/jquery/demo_test_post.asp", {
                        name: "Admin",
                        city: "London"
                    function(data, status) {
                        alert("Data: " + data + "\nStatus: " + status);


    <button>Send an HTTP POST request to a page and get the result back</button>
    <div id="output"></div>

Try it Yourself - Copy paste code in Online HTML Editor to see the result