Ajax differences:
Async: Boolean value that indicates whether the request is asynchronous mode. Async is important because it is used to control how JavaScript executes the request.
When set to true, the request will be sent in asynchronous mode, the JavaScript code will continue to execute without waiting for a response, and an event handler must be used to monitor the response of the request.
If Async is set to False, the request will be sent in synchronous mode, and JavaScript will wait until the response is received before continuing to execute the remaining code.
This means that if the response time is long, the user will not be able to interact with the browser until it receives a response.
For this reason, the best practice for AJAX application development is to use asynchronous requests to achieve data acquisition and to use synchronous requests to send and receive simple messages between servers.
This is useful for scenarios where you want the user to wait for a response, or if you want to receive very little data (for example, less than 1KB). For the usual amount of data or large amounts of data, it is best to use asynchronous calls.
For example, the following example shows an incorrect return result because the Ajax asynchronous request has not been completed and the function has already executed the return.
1 Asynchronous Request mode:
$.ajax ({ URL: ' Your URL ', data:{name:value}, Cache:false, async:true, type: ' POST ', DataType: ' json/xml/html ', success:function (result) {do something ....
2 Synchronous Request Mode
$.ajax ({ URL: ' Your URL ', data:{name:value}, Cache:false, async:false, type: ' POST ', dataType: ' json/xml/html ', success:function (result) {do something ... }});
The difference between an AJAX synchronous request and an asynchronous request