jQuery post()Method
Example 1
Load data from the server using an HTTP POST request:
$("button").click(function(){
$.post("demo_test.html",function(data,status){
alert("Data: " + data + "nStatus: " + status);
});
});
Try it Yourself »
Example 2
Use AJAX POST request to change the text of a <div> element:
$("input").keyup(function(){
txt=$("input").val();
$.post("demo_ajax_gethint.html",{suggest:txt},function(result){
$("span").html(result);
});
});
Try it Yourself »
Definition and Usage
The $.post() method loads data from the server using an HTTP POST request.
Syntax
$(selector).post(URL,data,function(data,status,xhr),dataType)
| Parameters | Description |
|---|---|
| URL | Required. Specifies which URL to send the request to. |
| data | Optional. Specifies data to send to the server along with the request. |
| function(data,status,xhr) | Optional. Specifies the function to run when the request succeeds. Additional parameters:
|
| dataType | Optional. Specifies the expected data type of the server response. By default, jQuery performs intelligent guessing. Possible types:
|
Other Extensions
jQuery AJAX Methods