Can any one tell the diffrence between Asynchronous AJAX and Synchronous AJAX ?

When a function executes Synchronously, the following statement is NOT executed until the previous one is done executing - ex:

/* here, the statements are executed one after the other. In other words, if the web server is experiencing delays and it takes 5 seconds to respond then you will see the second alert 5 seconds after the message "Checking Username".
*/
alert("Checking Username");
var username = makeSJAXCall();
alert(username);

By contrast, Asynchronous calls do NOT wait for completion before moving on to the next statement - ex:

/*
here you see the "Checking Username" message and almost immediately after that you will see the second alert. Since the Asynchronous function has not completed, username does not have a value and you should see undefined as the second message.

So how do you "campture/receive" the result. This is where the callback function comes into place, which is what is typically executed onreadystatechange.
*/
alert("Checking Username");
var username = makeAJAXCall();
alert(useranme);

thanks buddy

You are welcome.

Regards,
Hielo

PS: Don't forget to mark the thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.