tjSON - JQuery API Documentation
tjSON - JQuery API Documentation
getjson/
Blog (https://blog.jquery.com/)
Plugins (https://plugins.jquery.com/)
jQuery.getJSON()
Categories: Ajax (//api.jquery.com/category/ajax/) > Shorthand Methods (//api.jquery.com/
category/ajax/shorthand-methods/)
2 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
Deferred Object (// and texttatu parameters passed to the success callback are
api.jquery.com/ undefined.
category/deferred-
object/) As of jQuery 1.4, if the JSON file contains a syntax
error, the request will usually fail silently. Avoid frequent hand-
Deprecated (//
editing of JSON data for this reason. JSON is a data-interchange
api.jquery.com/
format with syntax rules that are stricter than those of
category/
JavaScript's object literal notation. For example, all strings
deprecated/)
represented in JSON, whether they are properties or values,
Deprecated 1.3 (// must be enclosed in double-quotes. For details on the JSON
api.jquery.com/ format, see https://json.org/ (https://json.org/).
category/
deprecated/
deprecated-1.3/) JSONP
Deprecated 1.7 (// If the URL includes the string "callback=?" (or similar, as defined by the
api.jquery.com/ server-side API), the request is treated as JSONP instead. See the
category/ discussion of the jonp data type in $.ajax() (/jQuer.ajax/) for
deprecated/ more details.
deprecated-1.7/)
The jqXHR Object
Deprecated 1.8 (//
api.jquery.com/ , all of jQuery's Ajax methods return a superset of the
category/ XMLHTTPRequet object. This jQuery XHR object, or "jqXHR," returned by
deprecated/ $.getJON() implements the Promise interface, giving it all the
deprecated-1.8/) properties, methods, and behavior of a Promise (see Deferred object (/
category/deferred-object/) for more information). The jqXHR.done() (for
Deprecated 1.9 (//
success), jqXHR.fail() (for error), and jqXHR.alwa() (for
api.jquery.com/
completion, whether success or error; added in jQuery 1.6) methods take
category/
a function argument that is called when the request terminates. For
deprecated/
information about the arguments this function receives, see the jqXHR
deprecated-1.9/)
Object (/jQuery.ajax/#jqXHR) section of the $.ajax() documentation.
Deprecated 1.10
(//api.jquery.com/ The Promise interface in jQuery 1.5 also allows jQuery's Ajax methods,
category/ including $.getJON() , to chain multiple .done() , .alwa() , and
.fail() callbacks on a single request, and even to assign these
deprecated/
deprecated-1.10- callbacks after the request may have completed. If the request is already
and-2.0/) complete, the callback is fired immediately.
3 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
deprecated/ 1 // Aign handler immediatel after making the requet,
2 // and rememer the jqxhr oject for thi requet
deprecated-3.2/)
3 var jqxhr = $.getJON( "example.jon", function()
4 conole.log( "ucce" );
Deprecated 3.3 (//
5 })
api.jquery.com/ 6 .done(function() {
category/ 7 conole.log( "econd ucce" );
8 })
deprecated/ 9 .fail(function() {
deprecated-3.3/) 10 conole.log( "error" );
11 })
Deprecated 3.4 (// 12 .alwa(function() {
api.jquery.com/ 13 conole.log( "complete" );
14 });
category/ 15
deprecated/ 16 // Perform other work here ...
deprecated-3.4/) 17
18 // et another completion function for the requet aove
Deprecated 3.5 (// 19 jqxhr.alwa(function() {
20 conole.log( "econd complete" );
api.jquery.com/ 21 });
category/
deprecated/
Deprecation Notice
deprecated-3.5/)
The jqXHR.ucce() , jqXHR.error() , and jqXHR.complete()
Dimensions (// callback methods are . You can use
api.jquery.com/ jqXHR.done() , jqXHR.fail() , and jqXHR.alwa() instead.
category/
Additional Notes:
dimensions/)
Due to browser security restrictions, most "Ajax" requests are
Effects (//
subject to the same origin policy (https://en.wikipedia.org/wiki/
api.jquery.com/
Same_origin_policy); the request can not successfully retrieve data
category/effects/) from a different domain, subdomain, port, or protocol.
Basics (//
Script and JSONP requests are not subject to the same origin
api.jquery.com/ policy restrictions.
category/effects/
basics/)
Examples:
Custom (//
Loads the four most recent pictures of Mount Rainier from the Flickr
api.jquery.com/
JSONP API.
category/effects/
custom-effects/)
Fading (//
api.jquery.com/
category/effects/
fading/)
Sliding (//
api.jquery.com/
category/effects/
sliding/)
4 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
Keyboard Events
Demo:
(//api.jquery.com/
category/events/
keyboard-events/)
Forms (//
api.jquery.com/
category/forms/)
Internals (//
Load the JSON data from test.js and access a name from the returned
api.jquery.com/
JSON data.
category/internals/)
5 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
DOM Insertion,
Around (//
api.jquery.com/
category/
manipulation/
dom-insertion-
around/)
DOM Insertion,
Inside (//
api.jquery.com/
category/
manipulation/
dom-insertion-
inside/)
DOM Insertion,
Outside (//
api.jquery.com/
category/
manipulation/
dom-insertion-
outside/)
DOM Replacement
(//api.jquery.com/
6 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
category/
manipulation/
dom-
replacement/)
General Attributes
(//api.jquery.com/
category/
manipulation/
general-
attributes/)
Miscellaneous (//
api.jquery.com/
category/
miscellaneous/)
Collection
Manipulation (//
api.jquery.com/
category/
miscellaneous/
collection-
manipulation/)
DOM Element
Methods (//
api.jquery.com/
category/
miscellaneous/
dom-element-
methods/)
Offset (//
api.jquery.com/
category/offset/)
Properties (//
api.jquery.com/
category/properties/)
Properties of
jQuery Object
Instances (//
api.jquery.com/
category/
properties/jquery-
object-instance-
properties/)
Properties of the
Global jQuery
Object (//
api.jquery.com/
category/
properties/global-
jquery-object-
properties/)
Removed (//
api.jquery.com/
category/removed/)
Selectors (//
api.jquery.com/
category/selectors/)
Attribute (//
api.jquery.com/
category/
selectors/
attribute-
selectors/)
Basic (//
api.jquery.com/
category/
selectors/basic-
css-selectors/)
8 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
Form (//
api.jquery.com/
category/
selectors/form-
selectors/)
Hierarchy (//
api.jquery.com/
category/
selectors/
hierarchy-
selectors/)
jQuery Extensions
(//api.jquery.com/
category/
selectors/jquery-
selector-
extensions/)
Traversing (//
api.jquery.com/
category/traversing/)
Filtering (//
9 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
api.jquery.com/
category/
traversing/
filtering/)
Miscellaneous
Traversing (//
api.jquery.com/
category/
traversing/
miscellaneous-
traversal/)
Utilities (//
api.jquery.com/
category/utilities/)
Version (//
api.jquery.com/
category/version/)
Version 1.0 (//
api.jquery.com/
category/version/
1.0/)
10 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
1.1.3/)
11 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
12 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
api.jquery.com/
category/version/
3.2/)
BOOKS
13 of 14 9/10/23, 22:29
jQuery.getJSON() | jQuery API Documentation https://api.jquery.com/jquery.getjson/
(https://jquery.org/license/) for more information. The
OpenJS Foundation (https://openjsf.org/) has registered
Forum (https://forum.jquery.com/)
trademarks and uses trademarks. For a list of trademarks of
the OpenJS Foundation (https://openjsf.org/), please see our Twitter (https://twitter.com/jquery)
Trademark Policy (https://trademark-policy.openjsf.org/) and
Trademark List (https://trademark-list.openjsf.org/). IRC (https://irc.jquery.org/)
Trademarks and logos not indicated on the list of OpenJS
Foundation trademarks (https://trademark-list.openjsf.org/) GitHub (https://github.com/jquery)
are trademarks™ or registered® trademarks of their
respective holders. Use of them does not imply any affiliation
with or endorsement by them. OpenJS Foundation Terms of
Use (https://terms-of-use.openjsf.org/), Privacy (https://
privacy-policy.openjsf.org/), and Cookie (https://
www.linuxfoundation.org/cookies) Policies also apply.
14 of 14 9/10/23, 22:29