Reason why the $.getjson () callback function did not execute

Source: Internet
Author: User

The $.getjson () method obtains JSON data using an AJAX HTTP GET request.

Grammar

$.getjson (Url,data,success (DATA,STATUS,XHR))

The URL must fill in the required request to send to that URL;

Data can optionally be sent to the server;

Success Optional data contains the information returned by the server,

Status contains the requested State ("Success", "Notmodified", "Error", "Timeout", "ParserError"),

XHR contains XMLHttpRequest objects;

Usage

test.json{    "name": "Zhangsan",    "age": 20}

  

test.js$ (document). Ready (function () {        $.getjson ("Test.json", function (data) {           console.log (data.name)        });});/ /zhangsan

The reason that the callback function of $.getjson is not executed

1 The callback function does not execute if the JSON object in the JSON file is malformed, such as the JSON key without double quotes, so if the callback function does not perform the first check that the callback function is in the correct format.

2 The callback function does not execute when a comment is included in the JSON.

When the callback function is still unable to execute after the modification, it should be considered that the cache is in mischief and the cache is cleaned up after modification. (Front-end development must remember to always clean up the cache)

Reason why the $.getjson () callback function did not execute

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.