Let's ask what ajax is asynchronous, What Is ajax synchronization, what is the difference between the two, or what is the difference between the two when applied. Let's ask what ajax is asynchronous, What Is ajax synchronization, what is the difference between the two, or what is the difference between the two when applied.
Reply content:
Let's ask what ajax is asynchronous, What Is ajax synchronization, what is the difference between the two, or what is the difference between the two when applied.
What is the relationship between synchronous Asynchronization and ajax?
Ajax is short for Asynchronous Javascript And XML.
What is asynchronous synchronization?
Asynchronous means that the callback result is sent to the current thread after the new thread completes processing for the request operation of the current thread.
Synchronization means that when you execute this program, you cannot execute other code and put it on Ajax, which is equivalent to not doing anything when Ajax gets a message, so Asynchronization is to enable him to run other parts of the Code normally when obtaining the code, and then the callback processing result will be fine.
In a series of event queues to be executed:
Synchronous operation: the compiler must execute one statement. If an event has not been completed, the system will wait until the event is executed!
Asynchronous Operation: it is like pulling this event out to another team and doing a separate task. When the program executes this asynchronous operation, it will be divided into two parts, some of them continue to execute the following program, and the other part will execute this Asynchronization separately, without affecting program loading!
From the user perspective, this will not make the user feel that he is waiting for a response!
In the ajax. open method, 3rd parameters are set to synchronous or asynchronous. Js class libraries such as prototype are generally asynchronous by default, that is, set to true.
First, in the case of synchronization, js will wait for the request to return and get the status. Onreadystatechange event handler is not required. While asynchronous processing requires onreadystatechange event processing, and the value is 4, and then the following content is processed correctly.
My own understanding is that ajax synchronization, that is, requests to the server and waits for the response from the server until the server responds. ajax is asynchronous, that is, after sending a request to the server, you do not have to wait for the response from the server and go back directly.
Here is an example.
Suppose there are three statements.
-
Method1 () takes 0.5 seconds
-
$. Ajax () takes 2 seconds
-
Method2 () takes 0.5 seconds
Synchronization: After 1 is executed, it is blocked when 2 is executed until ajax is all over. The execution of method 3 takes 3 seconds.
Asynchronous: After 1 is executed, 2 starts to execute, and 3 immediately runs non-blocking and goes down. Theory ends in 2.5 seconds
Synchronization = serial, asynchronous = parallel.
There is no such thing as ajax Asynchronization and synchronization. AJAX itself isAsynchronous request dataButRequest dataAndSynchronization.
That is, the XMLHttpRequest object containsSynchronous requestAndAsynchronous requestTwo usage methods. In those years, due to the profound impact of asynchronous Technology on development, AJAX technology became popular. People were also used to calling AJAX technology for data request to servers, but in fact there was still synchronization, it's just calledAJAX SynchronizationIt's just a convention.