Home > Back-end >  JQuery asynchronous AJAX summary
JQuery asynchronous AJAX summary

Time:09-26


~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Development tools and key technology: Vs JavaScript jQuery
The author: wang
Writing time: on May 5, 2020,
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

AJAX is a without reloading the whole web page, will be able to update part of the web technology
Traditional web page (do not use the AJAX) if need to update the content, necessary reloading the whole page,
There are a lot of using AJAX application case: sina weibo, Google maps, etc.
Asynchronous: refers to the process does not need to wait forever,
But continue to perform the following operations, regardless of the other processes,
When there is a message returns system will inform process for processing,
So that we can improve the efficiency of execution
Using HTML and CSS pages, express information
Using the XMLHttpRequest and web server for the exchange of asynchronous data
AJAX - sends a request to the server
Sends a request to the server, we use the XMLHttpRequest object open () and send () method:
Open (method, url, async) regulation of the type of request, a url and whether the asynchronous request is processed,
Parameter description:
Method: the type of request; GET or POST
Url: the location of the file on the server
Async: true (Asynchronous) or false (synchronous) Asynchronous
Send (string) : sends a request to the server,
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 $.
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,

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,

$. In 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,
  • Related