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

What are the considerations for ajaxSend ()

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces what matters needing attention in ajaxSend (), the article is very detailed, has a certain reference value, interested friends must read it!

No matter which Ajax request is sent, all ajaxSend processors will be executed. If we have to distinguish between different requests, we can pass the parameters to this processor. Each time the ajaxSend processor executes, it passes the event object, the jqXHR object (XMLHttpRequest object in jQuery 1.4), and the settings object object used to create the request. If the request fails, because JavaScript throws an exception and the exception object as the fourth parameter is passed to the handler. For example, we can limit our callback to only handle events and handle a particular URL:

$(document) .ajaxSend (function (event, jqxhr, settings) {

If (settings.url = = "ajax/test.html") {

$(".log") .text ("Triggered ajaxSend handler.")

}

})

Other considerations:

If the global option is set to false, the call to the $.ajax () or .ajaxSend () method will not be triggered.

Example:

Displays a message when the Ajax request is about to be sent.

$(document) .ajaxSend (function (event, request, settings) {

$("# msg") .append ("Starting request at" + settings.url + "")

})

The above is all the contents of the article "what are the points for attention in ajaxSend ()". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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