Home > Web Front-end > JS Tutorial > How to use jQuery getJSON() method

How to use jQuery getJSON() method

coldplay.xixi
Release: 2020-11-30 14:54:43
Original
3937 people have browsed it

Usage of jQuery getJSON() method: [getJSON()] method uses AJAX HTTP GET request to obtain JSON data. The syntax is [$(selector).getJSON(url,data,success(data,status, xhr)】.

How to use jQuery getJSON() method

The operating environment of this tutorial: windows7 system, jquery3.2.1 version, this method is suitable for all brands of computers.

Definition and usage

The getJSON() method uses AJAX's HTTP GET request to obtain JSON data.

Syntax

$(selector).getJSON(url,data,success(data,status,xhr))
Copy after login

Example

Use Ajax request to obtain JSON data and output the result:

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

How to use jQuery getJSON() method

The above is the detailed content of How to use jQuery getJSON() method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template