Home > front end >  JQuery asynchronous ajax
JQuery asynchronous ajax

Time:12-27

Knowledge:
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

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

3, the jQuery $.
the get () methodGrammar: $.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,

4, the jQuery $. 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,

The $5, 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,

6, to get the data method
1) to receive the form is submitted by means of parameter data: retrieve data forms four ways: (can receive the post and get submitted data)

2) by FormCollection to receive the data form: retrieve data forms four ways: only receives the post submission of data

. 3) via the Request Form/" name attribute value "to obtain the Form data: retrieve data forms four ways: can only receive the post submission of data

4) EntityClass entity class receive data: retrieve data forms four ways: you can receive the post and get submitted data

Create the entity class
  • Related