jQuery getJSON() Method
Example
Get JSON data using an AJAX request, and output the result:
$("button").click(function(){
$.getJSON("demo_ajax_json.js", function(result){
$.each(result, function(i, field){
$("div").append(field + " ");
});
});
});
Try it Yourself »
Definition and Usage
The getJSON() method is used to get JSON data using an AJAX HTTP GET request.
Syntax
$(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:
|
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.