Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use post and jqXHR objects

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to use post and jqXHR objects". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor learn how to use post and jqXHR objects.

The jqXHR Object (jqXHR object)

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). The jqXHR.done () (for success), jqXHR.fail () (for error), and jqXHR.always () (for completion, success or error) methods accept a function argument to be called when the request is terminated. For more information about the parameters that this function receives, see the $.ajax () section in the jqXHR Object documentation.

The Promise interface also allows jQuery's Ajax methods, including $.get (), to be associated with .done (), .fail (), and .always () 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 = $.post ("example.php", 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");})

Deprecation Notice (recommended precautions:)

The jqXHR.success (), jqXHR.error (), and jqXHR.complete () callback methods were introduced in jQuery 1.5, but are not recommended in jQuery 1.8 and are obsolete. They will eventually be canceled (removed), and your code should be ready for the second time, using jqXHR.done (), jqXHR.fail (), and jqXHR.always () instead.

At this point, I believe you have a deeper understanding of "how to use post and jqXHR objects". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report