CodesJava

Easy learning with example program codes

difference between ajax synchronous and asynchronous


Let’s see the open method signature first.

open(method,url,async,user,psw): It specifies the request.

Where:
method: the request type GET or POST
url: the file location
async: true (asynchronous) or false (synchronous)
user: optional user name
psw: optional password

Synchronous: We can send one request at one time and have to wait for the response before send the second request. i.e. It blocks the client browser until operation completes.

For Synchronous request set the async parameter to false.

Example:

xhttp.open("GET", "test.txt", false);

Asynchronous: We can send other request before getting the response of first request. i.e. It does not blocks the client browser.

For Asynchronous request set the async parameter to true.

Example:

xhttp.open("GET", "test.txt", true);
Posted in Ajax   


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap