What are the considerations for ajaxSend ()
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!