Ajax and ajax Technologies
AJAX, that isASynchronousJAvascriptANdXMLAllows you to update the page without refreshing the status and submit the page asynchronously.
Advantages:
- No plug-in support
- Excellent User Experience
- Improve Web program performance
- Reducing the burden on servers and bandwidth
Disadvantages:
- The forward and backward buttons are damaged.
- Insufficient support for search engines
- Lack of development and debugging tools
Synchronous and asynchronous
- Synchronization: that is, you must do one thing, and wait for the previous one to finish before you can do the next thing.
- Asynchronous: you do not need to wait until the previous task is finished.
JQuery encapsulates AJAX in three layers
Bottom layer: encapsulates some basic Ajax operations;
-
- Global Method: $. ajax ()
- The submitted data is submitted in data and post. The submitted data must be wrapped in "{}" and submitted in the form of "key: value ".
- When submitting the entire form, you can use form serialization "serialize ()" to submit the entire form.
- DecodeURIComponent (): deserialized data
- EncodeURIComponent (): serializes data. serialize () also calls this method for serialization.
- SerializeArray (): converts a form to json format.
- $. AjaxSetup (): initializes the data of $. ajax (), which is used to set the default value of the $. ajax () object.
Layer 2: encapsulates jQuery's Ajax;
-
- Local method:. load (url, data, callback)
- Suitable for asynchronous acquisition of static files
- Global Method: $. get (url, data, callback, type), $. post (url, data, callback, type)
- Can be obtained asynchronously with dynamic files
Layer 3: encapsulated get;
-
- Global Method: $. getJSON, $. getScript
Load request
$ (Document). ajaxStart (function): Method triggered when a request starts.
$ (Document). ajaxStop (function): Method triggered when the request ends
JSON and JSONP
If dataType is JSON, data cannot be obtained across domains. Add "? Callback =. When dataType is JSONP, cross-domain data can be obtained directly.
JQXHR object
Attributes and methods of the jQuery jqXHR object