Ajax-first knowledge, ajax first Knowledge

Source: Internet
Author: User

Ajax-first knowledge, ajax first Knowledge

Looking at the process of DRP, I learned Ajax again, and realized the charm of Ajax more deeply. Ajax is a technology or method.


Art. It presents our programs to users in a more perfect fashion. Let's join in the Ajax world.


Introduction
Full name:

AsynchronousJavaScript and XML.


Working principle:

The working principle of Ajax is equivalent to adding an intermediate layer (AJAX engine) between the user and the server, so that user operations and server responses are asynchronous. No

All user requests are submitted to the server. For example, some data verification and data processing are handed over to the Ajax engine for self-processing. Only the user must read the data from the server.

When new data is retrieved, the Ajax engine submits a request to the server.

Use the XmlHttpRequest object to send an asynchronous request to the server, obtain data from the server, and then use JavaScript to update the DOM.

Page.


Core technologies:

Asynchronous


Main members:

JavaScript, XMLHTTPRequest, DOM


Application:

Sina Weibo, Google maps, etc.


Synchronous and asynchronous

When Ajax is mentioned, synchronization and Asynchronization are inevitable.


Synchronization: it can be understood as a single thread or a "dead eye ". That is, after a function or method is executed, it waits for the system to return.

Value or message. At this time, the program is out of blocking. Other commands are executed only after the returned value or message is received.


Asynchronous: it can be understood as multithreading (asynchronous must be multithreading ). After the function or method is executed, you do not need to wait for the return value or message in a obstructive manner.

To delegate an asynchronous process to the system, when the system receives the return value or message, the system will automatically trigger the asynchronous process of the delegation to complete

The whole process.

Still don't understand? Synchronization means that you ask me to go to dinner. When I hear it, I will go to dinner with you. If I don't hear it, you will keep calling until I tell you to hear it.

Now, we can have dinner together. Asynchronous mode means that you call me and then eat on your own. After receiving the message, I may leave immediately or wait until I get off work. Institute

So, if you want to invite you to dinner, you can use the synchronous method. If you want to invite me to dinner, you can use the asynchronous method, so that you can save money.

Our Ajax only needs to apply Asynchronization to show its charm and improve the user experience. Speaking of this, we have to mention the core object of Ajax.

XMLHttpRequest. It is its existence that makes Ajax show its powerful functions to the world.

 

XMLHttpRequest

Here we will not detail the attributes and methods of XMLHttpRequest. Let's take a rough look at the working process of XMLHttpRequest:

These steps are intuitive: you need an instance of the XMLHttpRequest object to tell it how to do it if its status changes, and to which

And how to send the request, and finally guide XMLHttpRequest to send the request. Simply create an instance and tell it

What does he need to do and who will serve him.


Advantages and disadvantages

Any piece of work is not perfect, and Ajax is also the same. Since the emergence of Ajax, the discussion on it has never been stopped. Advantages:

 

However, its shortcomings are also obvious. Some people have summed up the "seven sins" of Ajax. Here we will not elaborate on it. I will roughly summarize its shortcomings:

Summary:

This is an article that helps you understand Ajax. Without much detailed technical explanation, Ajax is a very practical technology that can be improved.

Customer experience, but it is not perfect. It is not suitable for many scenarios, for example, when a large number of texts need to be replaced.

 


What are the ajax applications ...? For example, what are the advantages of this technology?

Currently, the most popular Weibo System Is ajax.
You will find that your Weibo posts will be refreshed with the latest information, and you will be refreshed with the latest Weibo posts, all of which are ajax.
There is also a widely used gmail and 163 mailbox, which will prompt when new emails arrive, which is also an ajax application.
There is also the drop-down prompt of Google and = Baidu input boxes, which is also an application of ajax.
Ajax allows you to update server information without interrupting the user status. This is an important step in customer experience in the future.

An Ajax problem of passing values

You can manually debug it yourself. For example, in the key step alert, check whether the value is the expected value.

Also, it is convenient to use the jquery framework to write JavaScript, including ajax, and it is not prone to errors. It's easy to learn jquery. It will be used in an hour or two.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.