🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 53 (from laksa116)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
3 hours ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://api.jquery.com/jQuery.getJSON/
Last Crawled2026-04-14 02:04:50 (3 hours ago)
First Indexed2013-08-16 07:59:12 (12 years ago)
HTTP Status Code200
Meta TitlejQuery.getJSON() | jQuery API Documentation
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
jQuery.getJSON( url [, data ] [, success ] ) Returns: jqXHR Description: Load JSON-encoded data from the server using a GET HTTP request. version added: 1.0 jQuery.getJSON( url [, data ] [, success ] ) url A string containing the URL to which the request is sent. data A plain object or string that is sent to the server with the request. success A callback function that is executed if the request succeeds. This is a shorthand Ajax function, which is equivalent to: 1 2 3 4 5 6 $.ajax({ dataType : "json" , url : url, data : data, success : success }); Data that is sent to the server is appended to the URL as a query string. If the value of the data parameter is a plain object, it is converted to a string and url-encoded before it is appended to the URL. Most implementations will specify a success handler: 1 2 3 4 5 6 7 8 9 10 11 $.getJSON( "ajax/test.json" , function ( data ) { var items = []; $.each( data, function ( key, val ) { items.push( "<li id='" + key + "'>" + val + "</li>" ); }); $( "<ul/>" , { "class" : "my-new-list" , html : items.join( "" ) }).appendTo( "body" ); }); This example, of course, relies on the structure of the JSON file: 1 2 3 4 5 { "one" : "Singular sensation" , "two" : "Beady little eyes" , "three" : "Little birds pitch by my doorstep" } Using this structure, the example loops through the requested data, builds an unordered list, and appends it to the body. The success callback is passed the returned data, which is typically a JavaScript object or array as defined by the JSON structure and parsed using the $.parseJSON() method. It is also passed the text status of the response. As of jQuery 1.5 , the success callback function receives a "jqXHR" object (in jQuery 1.4 , it received the XMLHttpRequest object). However, since JSONP and cross-domain GET requests do not use XHR , in those cases the jqXHR and textStatus parameters passed to the success callback are undefined. Important: As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently. Avoid frequent hand-editing of JSON data for this reason. JSON is a data-interchange format with syntax rules that are stricter than those of JavaScript's object literal notation. For example, all strings represented in JSON, whether they are properties or values, must be enclosed in double-quotes. For details on the JSON format, see https://json.org/ . JSONP If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the jsonp data type in $.ajax() for more details. The jqXHR Object As of jQuery 1.5 , all of jQuery's Ajax methods return a superset of the XMLHTTPRequest object. This jQuery XHR object, or "jqXHR," returned by $.getJSON() implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see Deferred object for more information). The jqXHR.done() (for success), jqXHR.fail() (for error), and jqXHR.always() (for completion, whether success or error; added in jQuery 1.6) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the jqXHR Object section of the $.ajax() documentation. The Promise interface in jQuery 1.5 also allows jQuery's Ajax methods, including $.getJSON() , to chain multiple .done() , .always() , and .fail() callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 // Assign handlers immediately after making the request, // and remember the jqxhr object for this request var jqxhr = $.getJSON( "example.json" , function ( ) { console .log( "success" ); }) .done( function ( ) { console .log( "second success" ); }) .fail( function ( ) { console .log( "error" ); }) .always( function ( ) { console .log( "complete" ); }); // Perform other work here ... // Set another completion function for the request above jqxhr.always( function ( ) { console .log( "second complete" ); }); Deprecation Notice The jqXHR.success() , jqXHR.error() , and jqXHR.complete() callback methods are removed as of jQuery 3.0 . You can use jqXHR.done() , jqXHR.fail() , and jqXHR.always() instead. Additional Notes: Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy ; the request can not successfully retrieve data from a different domain, subdomain, port, or protocol. Script and JSONP requests are not subject to the same origin policy restrictions. Examples: Example 1 Loads the four most recent pictures of Mount Rainier from the Flickr JSONP API. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 <!doctype html > < html lang = "en" > < head > < meta charset = "utf-8" > < title > jQuery.getJSON demo </ title > < style > img { height : 100px ; float : left; } </ style > < script src = "https://code.jquery.com/jquery-4.0.0.js" > </ script > </ head > < body > < div id = "images" > </ div > < script > ( function ( ) { var flickerAPI = "https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?" ; $.getJSON( flickerAPI, { tags : "mount rainier" , tagmode : "any" , format : "json" }) .done( function ( data ) { $.each( data.items, function ( i, item ) { $( "<img>" ).attr( "src" , item.media.m ).appendTo( "#images" ); if ( i === 3 ) { return false ; } }); }); })(); </ script > </ body > </ html > Demo: Example 2 Load the JSON data from test.js and access a name from the returned JSON data. 1 2 3 $.getJSON( "test.js" , function ( json ) { console .log( "JSON Data: " + json.users[ 3 ].name ); }); Example 3 Load the JSON data from test.js, passing along additional data, and access a name from the returned JSON data. If an error occurs, log an error message instead. 1 2 3 4 5 6 7 8 $.getJSON( "test.js" , { name : "John" , time : "2pm" } ) .done( function ( json ) { console .log( "JSON Data: " + json.users[ 3 ].name ); }) .fail( function ( jqxhr, textStatus, error ) { var err = textStatus + ", " + error; console .log( "Request Failed: " + err ); });
Markdown
- [jQuery](https://jquery.com/ "jQuery") - [jQuery UI](https://jqueryui.com/ "jQuery UI") - [jQuery Mobile](https://jquerymobile.com/ "jQuery Mobile") - [Sizzle](https://sizzlejs.com/ "Sizzle") - [QUnit](https://qunitjs.com/ "QUnit") - [Plugins](https://plugins.jquery.com/) - [Contribute](https://contribute.jquery.org/) - [CLA](https://cla.openjsf.org/) - [Style Guides](https://contribute.jquery.org/style-guide/) - [Bug Triage](https://contribute.jquery.org/triage/) - [Code](https://contribute.jquery.org/code/) - [Documentation](https://contribute.jquery.org/documentation/) - [Web Sites](https://contribute.jquery.org/web-sites/) - [Events](https://events.jquery.org/) - [Support](https://jquery.com/support/) - [Learning Center](https://learn.jquery.com/) - [Chat](https://jquery.com/support/) - [Stack Overflow](https://stackoverflow.com/tags/jquery/info) - [Report a bug](https://contribute.jquery.org/bug-reports/) - [OpenJS Foundation](https://openjsf.org/) - [Join](https://openjsf.org/join) - [Members](https://openjsf.org/members) - [jQuery Team](https://jquery.com/team) - [Governance](https://openjsf.org/governance) - [Conduct](https://code-of-conduct.openjsf.org/) - [Projects](https://openjsf.org/projects) ## [jQuery API Documentation](https://jquery.com/ "jQuery API Documentation") Navigation - [Download](https://jquery.com/download/) - [API Documentation](https://api.jquery.com/) - [Blog](https://blog.jquery.com/) - [Plugins](https://plugins.jquery.com/) - [Browser Support](https://jquery.com/browser-support/) - [Version Support](https://jquery.com/support/) # jQuery.getJSON() *** Categories: [Ajax](https://api.jquery.com/category/ajax/) \> [Shorthand Methods](https://api.jquery.com/category/ajax/shorthand-methods/) ## jQuery.getJSON( url \[, data \] \[, success \] )Returns: [jqXHR](http://api.jquery.com/Types/#jqXHR) **Description:** Load JSON-encoded data from the server using a GET HTTP request. - #### version added: [1\.0](https://api.jquery.com/category/version/1.0/)[jQuery.getJSON( url \[, data \] \[, success \] )](https://api.jquery.com/jQuery.getJSON/#jQuery-getJSON-url-data-success) - **url** Type: [String](http://api.jquery.com/Types/#String) A string containing the URL to which the request is sent. - **data** Type: [PlainObject](http://api.jquery.com/Types/#PlainObject) or [String](http://api.jquery.com/Types/#String) A plain object or string that is sent to the server with the request. - **success** Type: [Function](http://api.jquery.com/Types/#Function)( [PlainObject](http://api.jquery.com/Types/#PlainObject) data, [String](http://api.jquery.com/Types/#String) textStatus, [jqXHR](http://api.jquery.com/Types/#jqXHR) jqXHR ) A callback function that is executed if the request succeeds. This is a shorthand Ajax function, which is equivalent to: | | | |---|---| | 1 2 3 4 5 6 | | Data that is sent to the server is appended to the URL as a query string. If the value of the `data` parameter is a plain object, it is converted to a string and url-encoded before it is appended to the URL. Most implementations will specify a success handler: | | | |---|---| | 1 2 3 4 5 6 7 8 9 10 11 | | This example, of course, relies on the structure of the JSON file: | | | |---|---| | 1 2 3 4 5 | | Using this structure, the example loops through the requested data, builds an unordered list, and appends it to the body. The `success` callback is passed the returned data, which is typically a JavaScript object or array as defined by the JSON structure and parsed using the `$.parseJSON()` method. It is also passed the text status of the response. **As of jQuery 1.5**, the `success` callback function receives a ["jqXHR" object](https://api.jquery.com/jQuery.get/#jqxhr-object) (in **jQuery 1.4**, it received the `XMLHttpRequest` object). However, since JSONP and cross-domain GET requests do not use XHR, in those cases the `jqXHR` and `textStatus` parameters passed to the success callback are undefined. **Important:** As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently. Avoid frequent hand-editing of JSON data for this reason. JSON is a data-interchange format with syntax rules that are stricter than those of JavaScript's object literal notation. For example, all strings represented in JSON, whether they are properties or values, must be enclosed in double-quotes. For details on the JSON format, see <https://json.org/>. #### JSONP If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the `jsonp` data type in `$.ajax()` for more details. #### The jqXHR Object **As of jQuery 1.5**, all of jQuery's Ajax methods return a superset of the `XMLHTTPRequest` object. This jQuery XHR object, or "jqXHR," returned by `$.getJSON()` implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see [Deferred object](https://api.jquery.com/category/deferred-object/) for more information). The `jqXHR.done()` (for success), `jqXHR.fail()` (for error), and `jqXHR.always()` (for completion, whether success or error; added in jQuery 1.6) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the [jqXHR Object](https://api.jquery.com/jQuery.ajax/#jqXHR) section of the `$.ajax()` documentation. The Promise interface in jQuery 1.5 also allows jQuery's Ajax methods, including `$.getJSON()`, to chain multiple `.done()`, `.always()`, and `.fail()` callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately. | | | |---|---| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | | #### Deprecation Notice The `jqXHR.success()`, `jqXHR.error()`, and `jqXHR.complete()` callback methods are **removed as of jQuery 3.0**. You can use `jqXHR.done()`, `jqXHR.fail()`, and `jqXHR.always()` instead. ### Additional Notes: - Due to browser security restrictions, most "Ajax" requests are subject to the [same origin policy](https://en.wikipedia.org/wiki/Same_origin_policy "Same Origin Policy on Wikipedia"); the request can not successfully retrieve data from a different domain, subdomain, port, or protocol. - Script and JSONP requests are not subject to the same origin policy restrictions. ## Examples: ### Example 1 Loads the four most recent pictures of Mount Rainier from the Flickr JSONP API. | | | |---|---| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | | #### Demo: ### Example 2 Load the JSON data from test.js and access a name from the returned JSON data. | | | |---|---| | 1 2 3 | | ### Example 3 Load the JSON data from test.js, passing along additional data, and access a name from the returned JSON data. If an error occurs, log an error message instead. | | | |---|---| | 1 2 3 4 5 6 7 8 | | - [Ajax](https://api.jquery.com/category/ajax/) - [Global Ajax Event Handlers](https://api.jquery.com/category/ajax/global-ajax-event-handlers/) - [Helper Functions](https://api.jquery.com/category/ajax/helper-functions/) - [Low-Level Interface](https://api.jquery.com/category/ajax/low-level-interface/) - [Shorthand Methods](https://api.jquery.com/category/ajax/shorthand-methods/) - [Attributes](https://api.jquery.com/category/attributes/) - [Callbacks Object](https://api.jquery.com/category/callbacks-object/) - [Core](https://api.jquery.com/category/core/) - [CSS](https://api.jquery.com/category/css/) - [Data](https://api.jquery.com/category/data/) - [Deferred Object](https://api.jquery.com/category/deferred-object/) - [Deprecated](https://api.jquery.com/category/deprecated/) - [Deprecated 1.3](https://api.jquery.com/category/deprecated/deprecated-1.3/) - [Deprecated 1.7](https://api.jquery.com/category/deprecated/deprecated-1.7/) - [Deprecated 1.8](https://api.jquery.com/category/deprecated/deprecated-1.8/) - [Deprecated 1.9](https://api.jquery.com/category/deprecated/deprecated-1.9/) - [Deprecated 1.10 & 2.0](https://api.jquery.com/category/deprecated/deprecated-1.10-and-2.0/) - [Deprecated 3.0](https://api.jquery.com/category/deprecated/deprecated-3.0/) - [Deprecated 3.2](https://api.jquery.com/category/deprecated/deprecated-3.2/) - [Deprecated 3.3](https://api.jquery.com/category/deprecated/deprecated-3.3/) - [Deprecated 3.4](https://api.jquery.com/category/deprecated/deprecated-3.4/) - [Deprecated 3.5](https://api.jquery.com/category/deprecated/deprecated-3.5/) - [Deprecated 3.7](https://api.jquery.com/category/deprecated/deprecated-3.7/) - [Dimensions](https://api.jquery.com/category/dimensions/) - [Effects](https://api.jquery.com/category/effects/) - [Basics](https://api.jquery.com/category/effects/basics/) - [Custom](https://api.jquery.com/category/effects/custom-effects/) - [Fading](https://api.jquery.com/category/effects/fading/) - [Sliding](https://api.jquery.com/category/effects/sliding/) - [Events](https://api.jquery.com/category/events/) - [Browser Events](https://api.jquery.com/category/events/browser-events/) - [Document Loading](https://api.jquery.com/category/events/document-loading/) - [Event Handler Attachment](https://api.jquery.com/category/events/event-handler-attachment/) - [Event Object](https://api.jquery.com/category/events/event-object/) - [Form Events](https://api.jquery.com/category/events/form-events/) - [Keyboard Events](https://api.jquery.com/category/events/keyboard-events/) - [Mouse Events](https://api.jquery.com/category/events/mouse-events/) - [Forms](https://api.jquery.com/category/forms/) - [Internals](https://api.jquery.com/category/internals/) - [Manipulation](https://api.jquery.com/category/manipulation/) - [Class Attribute](https://api.jquery.com/category/manipulation/class-attribute/) - [Copying](https://api.jquery.com/category/manipulation/copying/) - [DOM Insertion, Around](https://api.jquery.com/category/manipulation/dom-insertion-around/) - [DOM Insertion, Inside](https://api.jquery.com/category/manipulation/dom-insertion-inside/) - [DOM Insertion, Outside](https://api.jquery.com/category/manipulation/dom-insertion-outside/) - [DOM Removal](https://api.jquery.com/category/manipulation/dom-removal/) - [DOM Replacement](https://api.jquery.com/category/manipulation/dom-replacement/) - [General Attributes](https://api.jquery.com/category/manipulation/general-attributes/) - [Style Properties](https://api.jquery.com/category/manipulation/style-properties/) - [Miscellaneous](https://api.jquery.com/category/miscellaneous/) - [Collection Manipulation](https://api.jquery.com/category/miscellaneous/collection-manipulation/) - [Data Storage](https://api.jquery.com/category/miscellaneous/data-storage/) - [DOM Element Methods](https://api.jquery.com/category/miscellaneous/dom-element-methods/) - [Setup Methods](https://api.jquery.com/category/miscellaneous/setup-methods/) - [Offset](https://api.jquery.com/category/offset/) - [Properties](https://api.jquery.com/category/properties/) - [Properties of jQuery Object Instances](https://api.jquery.com/category/properties/jquery-object-instance-properties/) - [Properties of the Global jQuery Object](https://api.jquery.com/category/properties/global-jquery-object-properties/) - [Removed](https://api.jquery.com/category/removed/) - [Selectors](https://api.jquery.com/category/selectors/) - [Attribute](https://api.jquery.com/category/selectors/attribute-selectors/) - [Basic](https://api.jquery.com/category/selectors/basic-css-selectors/) - [Basic Filter](https://api.jquery.com/category/selectors/basic-filter-selectors/) - [Child Filter](https://api.jquery.com/category/selectors/child-filter-selectors/) - [Content Filter](https://api.jquery.com/category/selectors/content-filter-selector/) - [Form](https://api.jquery.com/category/selectors/form-selectors/) - [Hierarchy](https://api.jquery.com/category/selectors/hierarchy-selectors/) - [jQuery Extensions](https://api.jquery.com/category/selectors/jquery-selector-extensions/) - [Visibility Filter](https://api.jquery.com/category/selectors/visibility-filter-selectors/) - [Traversing](https://api.jquery.com/category/traversing/) - [Filtering](https://api.jquery.com/category/traversing/filtering/) - [Miscellaneous Traversing](https://api.jquery.com/category/traversing/miscellaneous-traversal/) - [Tree Traversal](https://api.jquery.com/category/traversing/tree-traversal/) - [Utilities](https://api.jquery.com/category/utilities/) - [Version](https://api.jquery.com/category/version/) - [Version 1.0](https://api.jquery.com/category/version/1.0/) - [Version 1.0.4](https://api.jquery.com/category/version/1.0.4/) - [Version 1.1](https://api.jquery.com/category/version/1.1/) - [Version 1.1.2](https://api.jquery.com/category/version/1.1.2/) - [Version 1.1.3](https://api.jquery.com/category/version/1.1.3/) - [Version 1.1.4](https://api.jquery.com/category/version/1.1.4/) - [Version 1.2](https://api.jquery.com/category/version/1.2/) - [Version 1.2.3](https://api.jquery.com/category/version/1.2.3/) - [Version 1.2.6](https://api.jquery.com/category/version/1.2.6/) - [Version 1.3](https://api.jquery.com/category/version/1.3/) - [Version 1.4](https://api.jquery.com/category/version/1.4/) - [Version 1.4.1](https://api.jquery.com/category/version/1.4.1/) - [Version 1.4.2](https://api.jquery.com/category/version/1.4.2/) - [Version 1.4.3](https://api.jquery.com/category/version/1.4.3/) - [Version 1.4.4](https://api.jquery.com/category/version/1.4.4/) - [Version 1.5](https://api.jquery.com/category/version/1.5/) - [Version 1.5.1](https://api.jquery.com/category/version/1.5.1/) - [Version 1.6](https://api.jquery.com/category/version/1.6/) - [Version 1.7](https://api.jquery.com/category/version/1.7/) - [Version 1.8](https://api.jquery.com/category/version/1.8/) - [Version 1.9](https://api.jquery.com/category/version/1.9/) - [Version 1.11 & 2.1](https://api.jquery.com/category/version/1.11-and-2.1/) - [Version 1.12 & 2.2](https://api.jquery.com/category/version/1.12-and-2.2/) - [Version 3.0](https://api.jquery.com/category/version/3.0/) - [Version 3.1](https://api.jquery.com/category/version/3.1/) - [Version 3.2](https://api.jquery.com/category/version/3.2/) - [Version 3.3](https://api.jquery.com/category/version/3.3/) - [Version 3.4](https://api.jquery.com/category/version/3.4/) - [Version 3.5](https://api.jquery.com/category/version/3.5/) - [Version 3.6](https://api.jquery.com/category/version/3.6/) - [Version 3.7](https://api.jquery.com/category/version/3.7/) - [Version 4.0](https://api.jquery.com/category/version/4.0/) ### Books - [![Learning jQuery 4th Edition by Karl Swedberg and Jonathan Chaffer](https://api.jquery.com/wp-content/themes/jquery/content/books/learning-jquery-4th-ed.jpg) Learning jQuery Fourth Edition Karl Swedberg and Jonathan Chaffer](https://www.packtpub.com/en-us/product/learning-jquery-fourth-edition-9781782163152) - [![jQuery in Action by Bear Bibeault, Yehuda Katz, and Aurelio De Rosa](https://api.jquery.com/wp-content/themes/jquery/content/books/jquery-in-action.jpg) jQuery in Action Bear Bibeault, Yehuda Katz, and Aurelio De Rosa](https://www.manning.com/books/jquery-in-action-third-edition) - [![jQuery Succinctly by Cody Lindley](https://api.jquery.com/wp-content/themes/jquery/content/books/jquery-succinctly.jpg) jQuery Succinctly Cody Lindley](https://www.syncfusion.com/ebooks/jquery) - [Learning Center](https://learn.jquery.com/) - [Chat](https://jquery.com/support/) - [Twitter](https://twitter.com/jquery) - [GitHub](https://github.com/jquery) Copyright 2026 [OpenJS Foundation](https://openjsf.org/) and jQuery contributors. All rights reserved. See [jQuery License](https://jquery.com/license/) for more information. The [OpenJS Foundation](https://openjsf.org/) has registered trademarks and uses trademarks. For a list of trademarks of the [OpenJS Foundation](https://openjsf.org/), please see our [Trademark Policy](https://trademark-policy.openjsf.org/) and [Trademark List](https://trademark-list.openjsf.org/). Trademarks and logos not indicated on the [list of OpenJS Foundation trademarks](https://trademark-list.openjsf.org/) 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/), [Code of Conduct](https://code-of-conduct.openjsf.org/), and [Cookie](https://www.linuxfoundation.org/cookies) Policies also apply. [Web hosting by Digital Ocean](https://www.digitalocean.com/) \| [CDN by Fastly](https://www.fastly.com/) \| [Powered by WordPress](https://wordpress.org/)
Readable Markdown
## jQuery.getJSON( url \[, data \] \[, success \] )Returns: [jqXHR](http://api.jquery.com/Types/#jqXHR) **Description:** Load JSON-encoded data from the server using a GET HTTP request. - #### version added: [1\.0](https://api.jquery.com/category/version/1.0/)[jQuery.getJSON( url \[, data \] \[, success \] )](https://api.jquery.com/jQuery.getJSON/#jQuery-getJSON-url-data-success) - **url** A string containing the URL to which the request is sent. - **data** A plain object or string that is sent to the server with the request. - **success** A callback function that is executed if the request succeeds. This is a shorthand Ajax function, which is equivalent to: | | | |---|---| | 1 2 3 4 5 6 | | Data that is sent to the server is appended to the URL as a query string. If the value of the `data` parameter is a plain object, it is converted to a string and url-encoded before it is appended to the URL. Most implementations will specify a success handler: | | | |---|---| | 1 2 3 4 5 6 7 8 9 10 11 | | This example, of course, relies on the structure of the JSON file: | | | |---|---| | 1 2 3 4 5 | | Using this structure, the example loops through the requested data, builds an unordered list, and appends it to the body. The `success` callback is passed the returned data, which is typically a JavaScript object or array as defined by the JSON structure and parsed using the `$.parseJSON()` method. It is also passed the text status of the response. **As of jQuery 1.5**, the `success` callback function receives a ["jqXHR" object](https://api.jquery.com/jQuery.get/#jqxhr-object) (in **jQuery 1.4**, it received the `XMLHttpRequest` object). However, since JSONP and cross-domain GET requests do not use XHR, in those cases the `jqXHR` and `textStatus` parameters passed to the success callback are undefined. **Important:** As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently. Avoid frequent hand-editing of JSON data for this reason. JSON is a data-interchange format with syntax rules that are stricter than those of JavaScript's object literal notation. For example, all strings represented in JSON, whether they are properties or values, must be enclosed in double-quotes. For details on the JSON format, see <https://json.org/>. #### JSONP If the URL includes the string "callback=?" (or similar, as defined by the server-side API), the request is treated as JSONP instead. See the discussion of the `jsonp` data type in `$.ajax()` for more details. #### The jqXHR Object **As of jQuery 1.5**, all of jQuery's Ajax methods return a superset of the `XMLHTTPRequest` object. This jQuery XHR object, or "jqXHR," returned by `$.getJSON()` implements the Promise interface, giving it all the properties, methods, and behavior of a Promise (see [Deferred object](https://api.jquery.com/category/deferred-object/) for more information). The `jqXHR.done()` (for success), `jqXHR.fail()` (for error), and `jqXHR.always()` (for completion, whether success or error; added in jQuery 1.6) methods take a function argument that is called when the request terminates. For information about the arguments this function receives, see the [jqXHR Object](https://api.jquery.com/jQuery.ajax/#jqXHR) section of the `$.ajax()` documentation. The Promise interface in jQuery 1.5 also allows jQuery's Ajax methods, including `$.getJSON()`, to chain multiple `.done()`, `.always()`, and `.fail()` callbacks on a single request, and even to assign these callbacks after the request may have completed. If the request is already complete, the callback is fired immediately. | | | |---|---| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | | #### Deprecation Notice The `jqXHR.success()`, `jqXHR.error()`, and `jqXHR.complete()` callback methods are **removed as of jQuery 3.0**. You can use `jqXHR.done()`, `jqXHR.fail()`, and `jqXHR.always()` instead. ### Additional Notes: - Due to browser security restrictions, most "Ajax" requests are subject to the [same origin policy](https://en.wikipedia.org/wiki/Same_origin_policy "Same Origin Policy on Wikipedia"); the request can not successfully retrieve data from a different domain, subdomain, port, or protocol. - Script and JSONP requests are not subject to the same origin policy restrictions. ## Examples: ### Example 1 Loads the four most recent pictures of Mount Rainier from the Flickr JSONP API. | | | |---|---| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | | #### Demo: ### Example 2 Load the JSON data from test.js and access a name from the returned JSON data. | | | |---|---| | 1 2 3 | | ### Example 3 Load the JSON data from test.js, passing along additional data, and access a name from the returned JSON data. If an error occurs, log an error message instead. | | | |---|---| | 1 2 3 4 5 6 7 8 | |
Shard53 (laksa)
Root Hash657907979407719853
Unparsed URLcom,jquery!api,/jQuery.getJSON/ s443