Home > front end >  Asynchronous ajax JavaScript jQuery
Asynchronous ajax JavaScript jQuery

Time:09-19

//1.1 $. In the jQuery ajax ({Settings}) method
/*
$. Ajax ({Settings});
Type: type, "POST" or "GET", the default value is "GET"
Url: send a request address
Async: set the asynchronous (default: true) under the default Settings, all requests for an asynchronous request, if you need to send a synchronous request,
Please leave this option is set to false, the attention, a synchronous request will lock the browser, users can other operation must wait for request to complete before execution,
Data: is an object that request data sent to the server along with
DataType: expect the server returns the data type of the, if not specified, the jQuery automatically according to the HTTP packet MIME information intelligent judgment,
Generally we use the json format, can be set to "json"
Success: it is a way, after the success of the request of the callback function, the incoming data after the return, and a string containing success code
Error: is a method and request failure is call this function, the incoming XMLHttpRequest object
*/
//in the jQuery ajax method to get data from the server

//in the jQuery ajax method will form data submitted to the server
//1.2 form serialization
/*
Serialize () sequence form content as a string for the Ajax request
SerializeArray () serialized form elements (like 'serialize ()' method) returns a JSON data structure,
Note: this method returns a JSON object rather than a JSON string, you need to use a plug-in or a third-party library to string operation
Returns a JSON object is composed of an array of objects, each object contains one or two of value on - the name and value parameters

//in the jQuery 1.0 $.
the get () method/*
Grammar: $.get (url, [data], [callback], [type])
Description: HTTP GET requests via remote load information,
This is a simple GET request function to replace the complex $. Ajax, can the callback function is invoked when request is successful, if you need to go wrong to perform functions, please use $. Ajax,
Parameter description:
Url: send a request address,
Data: sent the Key/value parameter,
The callback: send success callback function,
Type: return content format, XML, HTML, script, json, text, _default,
*/

//in the jQuery 1.1 $. Post () method
/*
Grammar: $.post (url, [data], [callback], [type])
Description: through remote HTTP POST request load information,
This is a simple function of the POST request to replace the complex $. Ajax, can the callback function is invoked when request is successful, if you need to go wrong when performing functions, please use $. Ajax,
Parameter description:
Url: send a request address,
Data: sent the Key/value parameter,
The callback: send success callback function,
Type: return content format, XML, HTML, script, json, text, _default,
*/

//1.3 $. In the jQuery getJSON method ()
/*
Grammar: $. GetJSON (url, [data], [callback])
Description: through HTTP GET request load JSON data
Parameter description:
Url: send a request address,
Data: sent the Key/value parameter,
The callback: send success callback function,
*/

CodePudding user response:

  • Related