How to deal with the actual transmission of Ajax data
Today, the editor will share with you the relevant knowledge points about how to deal with the actual transmission of Ajax data. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
JQuery.ajaxTransport (dataType, handler (options, originalOptions, jqXHR))
Description: create an object that handles the actual transfer of Ajax data.
DataType
Type: String
A string that identifies the data type used
Handler (options, originalOptions, jqXHR)
Type: Function ()
A handler that returns a new transport object using the data type provided in the first parameter.
Transport is an object that provides two methods, send and abort, which are internally used to make requests by $.ajax (). Transport is the most advanced method to enhance $. Ajax () and should only be used as a last resort when pre-filters (prefilters) and converters (converters) cannot meet your needs.
Since each request needs its own instance of a transport object, the transport cannot be registered directly. Therefore, you should provide a function instead of return transfer (transport).
The transports factory registration uses $.ajaxTransport (). A typical registration looks like this:
$.ajaxTransport (function (options, originalOptions, jqXHR) {
If (/ * transportCanHandleRequest * /) {
Return {
Send: function (headers, completeCallback) {
/ * send code * /
}
Abort: function () {
/ * abort code * /
}
}
}
})
These are all the contents of the article "how to handle the actual transmission of Ajax data". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.