Home > front end >  Asynchronous ajax JavaScript
Asynchronous ajax JavaScript

Time:12-27

Asynchronous ajax JavaScript
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Development tools and key technology: Adobe Dreamweaver JavaScript
Author: Peng Qiwang
Writing time: on May 5, 2020,
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
In the jQuery ajax
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 will form data submitted to the server
1.2 the 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 2.0 $. Post () $. The get () $. GetJSON ()
In the jQuery 1.0 $.
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,
2. In 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,
$.post ("/jQueryAjax getDataByRequest, "{name: strname, sex: strsex, address: straddress}, function (MSG) {alert (MSG); });
3. 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,
$. GetJSON () method can only accept the return value for the json data
$. GetJSON ("/jQueryAjax getDataByEntityClass frmData, function (MSG) {
console.log(msg);
Alert (MSG);
});
1. To get the data method
Retrieve data forms four ways: (can receive the post and get the data submitted)
1. Receive the form submission data by means of parameter
Retrieve data forms four ways: can only receive the post submission of data
2. To receive the form data by FormCollection
Retrieve data forms four ways: can only receive the post submission of data
3. By Request. The Form/" name attribute value "to obtain the Form data
Retrieve data forms four ways: you can receive the post and get submitted data
4. EntityClass entity class receive data
  • Related