Default request parameter var _options = { url:null, //Request Connection Address type: ' GET ', //request type (get,post) Data:null, Post when the request body dataType: ' text ', //Return the requested type, have TEXT/JSON/JSONP (generally JSON) Jsonp for cross-domain, can only be get mode JSONP: ' Callback ', //JSONP The requested flag, generally does not change (passed to the request handler or page, to obtain the JSONP callback function name of the parameter name) jsonpcallback: ' Jsonpcallback ', // Jsonp the function name of the request Async:true, //Whether asynchronous True indicates that asynchronous false indicates synchronous Cache:true, //whether the cache Timeout:null, //Set the request timeout number, if the server response time exceeds the set time, then enter error (Error handling) ContentType: ' application/ X-www-form-urlencoded ', beforesend:null,//before sending the function callback, you can do a bit of data sent to the background when the Operation Success:null, // The request succeeds callback function global:false,//disables the global Ajax event Error:null,/ /request failed callback Complete:null,//The callback function after the request is completed ( Called when the request succeeds or fails. Parameters: XMLHttpRequest Object, Success information string. headers:{}//Request header }
AJAX is a technique for exchanging data with a server that can update a part of a Web page without re-loading the entire page.
URL (String): The address used to request data
Type (string): Get or Post mode,
The Get method exposes the data that is sent to the front end (the data is connected directly to the address, the data size can only be transferred: 1024, note that this restriction is generated by the browser or server), is not secure, so it is generally used for query operations (no threat to database data), Get cache issues, will be cached by the browser, data security issues serious
Post mode will not expose the data, relatively safe, generally used for, add, delete, modify and other operations. Transfer data size: 2M;
Data: Request the information,
DataType: The type returned by the request, TXT/JSON/JSONP, JSONP represents the cross-domain
JSONP: The function name of the callback function,,, only the setting Datatype:jsonp this property to work
Async: Synchronous asynchronous Flag By default is true asynchronous,,, synchronous, will block the operation of the program, the request is completed before continuing to run the script code, asynchronous, the request process does not block the code to run.
Cache: The default is true, indicates whether the cache is required, if true, sends the same request, the second time will be taken from the cached data
Timeout (number type): Sets the time-out period and enters error if the server response time exceeds the set time
ContentType: "Application/x-www-form-urlencoded", this is set for post.
Global:false Prohibit global AJAX settings
Header: Set the request header information,, generally we need to add version information, browser information, language, time, all to add here
Beforesend: callback function, for XML to send () method before, can be done, data re-add, confirm interface, etc.
Success: Successful callback function, parameter: Server return data, return status
Error: Failed callback function, parameter: XMLHttpRequest object, error message, (possibly) the wrong object being captured.
Complete: Callback after request data is completed, failure or success will come in here,, but the order of the function call is Succexx-error-complete
Attached: JQ ajax sequence of execution of each event
1.ajaxStart (Global event)
2.beforeSend
3.ajaxSend (Global event)
4.success
5.ajaxSuccess (Global event)
6.error
7.ajaxError (Global event)
8.complete
9.ajaxComplete (Global event)
10.ajaxStop (Global event)
jquery Ajax Parameters