Easy Tutorial
❮ Jquery Cookie Plugin Html Removeprop ❯

jQuery getJSON() Method

jQuery AJAX Methods

Example

Use Ajax to request JSON data and output the results:

$(document).ready(function(){
    $("button").click(function(){
        $.getJSON("demo_ajax_json.js",function(result){
            $.each(result, function(i, field){
                $("div").append(field + " ");
            });
        });
    });
});

Definition and Usage

The getJSON() method uses an AJAX HTTP GET request to fetch JSON data.


Syntax

Parameter Description
url Required. Specifies the URL to which the request is sent.
data Optional. Specifies the data to be sent to the server.
success(data, status, xhr) Optional. Specifies a function to be run when the request succeeds. <br> Additional parameters: data - contains the data returned from the server <br> status - contains the status of the request ("success", "notmodified", "error", "timeout", "parsererror") <br> xhr - contains the XMLHttpRequest object

jQuery AJAX Methods

❮ Jquery Cookie Plugin Html Removeprop ❯