jQuery getJSON () विधि :
उदाहरण
AJAX अनुरोध का उपयोग करके JSON डेटा प्राप्त करें, और परिणाम आउटपुट करें:
$("button").click(function(){
$.getJSON("demo_ajax_json.js", function(result){
$.each(result, function(i, field){
$("div").append(field + " ");
});
});
});
परिभाषा और उपयोग
AJAX HTTP GET अनुरोध का उपयोग करके JSON डेटा प्राप्त करने के लिए getJSON () विधि का उपयोग किया जाता है।
वाक्य - विन्यास
$(selector).getJSON(url,data,success(data,status,xhr))
Parameter | Description |
---|---|
url | Required. Specifies the url to send the request to |
data | Optional. Specifies data to be sent to the server |
success(data,status,xhr) | Optional. Specifies the function to run if the request succeeds Additional parameters:
|