jQuery पोस्ट () विधि
उदाहरण 1
HTTP POST अनुरोध का उपयोग करके सर्वर से डेटा लोड करें:
$("button").click(function(){
$.post("demo_test.asp", function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
उदाहरण 2
AJAX POST अनुरोध का उपयोग करके <div> तत्व का टेक्स्ट बदलें:
$("input").keyup(function(){
var txt = $("input").val();
$.post("demo_ajax_gethint.asp", {suggest: txt}, function(result){
$("span").html(result);
});
});
परिभाषा और उपयोग
$.post() विधि HTTP POST अनुरोध का उपयोग कर सर्वर से डेटा लोड करती है।
वाक्य - विन्यास
$(selector).post(URL,data,function(data,status,xhr),dataType)
Parameter | Description |
---|---|
URL | Required. Specifies the 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 a function to run if the request succeeds Additional parameters:
|
dataType | Optional. Specifies the data type expected of the server response. By default jQuery performs an automatic guess. Possible types:
|