jQuery getJSON() Method

Jak
Jak
Member
858 Points
132 Posts

jQuery getJSON() Method

Views: 9137
Total Answered: 1
Total Marked As Answer: 0
Posted On: 17-Mar-2015 13:47

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Teacher
4822 Points
23 Posts
         

Hi,

The getJSON() method is used to get JSON data using an AJAX HTTP GET request.

Syntax:

$.getJSON(url,data,success(data,status,xhr))
 

Where:
url
Type: String
A string containing the URL to which the request is sent.

data
Type: PlainObject or String
A plain object or string that is sent to the server with the request.

success
Type: Function( PlainObject data, String textStatus, jqXHR jqXHR )
A callback function that is executed if the request succeeds.

Example:

$.getJSON("demo_ajax_json.js", function (result) {
$.each(result, function (i, field) {
$("div").append(field + " ");
});
});
 
OR
 
This is a shorthand Ajax function, which is equivalent to:
 
$.ajax({
  dataType: "json",
    url: url,
    data: data,
     success: success
});

 

Posted On: 17-Mar-2015 14:20
 Log In to Chat