Home > Web Front-end > JS Tutorial > A brief discussion on Ajax and its advantages and disadvantages

A brief discussion on Ajax and its advantages and disadvantages

亚连
Release: 2018-05-25 10:45:38
Original
1979 people have browsed it

I have been learning about AJAX recently and checked some information about AJAX online, mainly about the technical introduction of AJAX and its advantages and disadvantages. Here, I would like to make a small summary of the information I collected. Most of the information comes from the Internet. I will only make a classification summary here. I hope it will be helpful to friends who are learning AJAX like me.

AJAX, Asynchronous Javascript And XML, can realize non-refresh status update page and asynchronous submission

Advantages:

No plug-in support required
Excellent user experience
Improve Web program performance
Reduce the burden on servers and broadband

Disadvantages:

The forward and back buttons are broken
Search The engine's support is not enough
Lack of development and debugging tools

Synchronization and asynchronous

Synchronization: that is, you must do one thing one by one and wait for the previous one to be completed. Before you can do the next thing
Asynchronous: You don’t need to wait until the previous thing is finished, you can do multiple things at the same time

JQuery has three layers of encapsulation of AJAX

The lowest layer: encapsulates some basic Ajax operations;

Global method: $.ajax()
The submitted data is in data, submitted in post mode, and the submitted data must be wrapped with "{}" , submit in the form of "key:value"
When submitting the entire form, you can use form serialization "serialize()" to submit the entire form
decodeURIComponent(): deserialize the data
encodeURIComponent() : Serialize the data, serialize() also calls this method for serialization
serializeArray(): Convert the form into json form
$.ajaxSetup(): Initialize the data of $.ajax(), used for setting Default value of $.ajax() object
Second layer: Ajax encapsulating jQuery;

Partial method: .load(url,data,callback)
More suitable for asynchronous acquisition of static files
Global methods: $.get(url,data,callback,type),$.post(url,data,callback,type)
can be obtained asynchronously with dynamic files
The third layer: encapsulated get;

Global method: $.getJSON,$.getScript

Loading request

 $(document).ajaxStart(function): Request starts When the request ends, the triggered method

When the dataType is JSON, data cannot be obtained across domains. You must add "?callback=" after adding the domain name to achieve cross-domain call data. When dataType is JSONP, cross-domain data can be obtained directly.

JQXHR Object

The properties and methods of jQuery jqXHR object

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future. Related articles:

Ajax method of reading properties resource file data

Ajax method to regularly update a certain piece of content on the page

Ajax method to get response content length

The above is the detailed content of A brief discussion on Ajax and its advantages and disadvantages. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template