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