Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the jqXHR object of jQuery.getJSON

Shulou Source: shulou.com Published: 2022-06-01 07:34:52 09月12日 Update

This article mainly shows you "what is the jqXHR object of jQuery.getJSON", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what is the jqXHR object of jQuery.getJSON?"

If the URL contains the string "callback=?" (or similar parameters, depending on how the server-side API is defined), the request is considered to be in JSONP form. For more details on jsonp data types, see $.ajax ().

The jqXHR Object (jqXHR object)

Note: it is estimated that the jQuery official did not update this api in time, which is different from the description of the jqXHR object in jQuery.get () api.

Starting with jQuery 1.5, all jQuery's Ajax methods return a superset of XMLHTTPRequest objects. This jQuery XHR object, or "jqXHR," returned through the $. Get () method, implements the Promise interface so that it has all the properties, methods, and behaviors of Promise (see Deferred object for more information). For ease of use in $.ajax (), the jQuery XHR object $.ajax () also provides .error () .success () and .complete () methods. These methods take a function argument that is called when the request is terminated. This function takes the same parameters as the callback function name of $.ajax ().

The Promise interface also allows jQuery's Ajax methods, including $.getJSON (), to be associated with .success (), .complete (), and .error () callbacks in a separate request, and even allows you to assign callbacks after the request has been completed. If the request has been completed, the callback function is called immediately.

/ / Assign handlers immediately after making the request

/ / and remember the jqxhr object for this request

Var jqxhr = $.getJSON ("example.json", function () {

Alert ("success")

})

.success (function () {alert ("second success");})

.error (function () {alert ("error");})

.complete (function () {alert ("complete");})

/ / perform other work here...

/ / Set another completion function for the request above

Jqxhr.complete (function () {alert ("second complete");})

The above is all the content of the article "what is the jqXHR object of jQuery.getJSON?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Objects functions methods contents parameters more articles interfaces learning help same information depending on characters strings official attributes differences forms data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple MariaDB Microsoft Huawei