The post() method in the jQuery is used to request data from the server with a post request. It is used to display the returned result from the requested webpage. In jQuery, that the post () method sends request along with some information using an HTTP POST request.

Syntax of .post()

(selector).post(URL,data,callback_function(data,status,xhr),dataType)
Example Script using .post()
<script>
$(document).ready(function(){
  $("button").click(function(){
    $.post("demo_test_post.asp",
    {
      name: "Sophia",
      city: "Hyderabad"
    },
    function(data,status){
      alert("Data: " + data + "\nStatus: " + status);
    });
  });
});
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *