Hi i am new to ajax and i am little bit confused with the word asynchronous. why is the word asynchronous used for ajax? what is it not in sync with? somebody pls expalin me why the word asynchronous? and how is it justified in ajax? Thanking you in advance.

Asynchronous just means that a call is made to e.g. a function, but that the code (next statement) won't wait until a response is received.

Hi i did understood little bit. You mean to say xmlhttprequest makes a request but it does not wait for responce and the next statement gets executed in the javascript. is this what you are saying?

Yes, that is what I mean, although I am not sure if XmlHttpRequest is a good example.

Yes, that is what I mean, although I am not sure if XmlHttpRequest is a good example.

What do you mean XMLHttpRequest isn't a good example? XMLHttpRequest IS Ajax, isn't it?

Yes. Although at the time of posting I wasn't sure if XMLHttpRequest was asynchronous , but now I'm sure it is. (Not every function call is asynchronous by default.)

XMLHttpRequest can behave either synchronously or asynchronously, as determined by the third parameter in the line of the form xmlhttp.open("GET", url, true); .

With synchronous behaviour, javascript execution is suspended (after sending the request) until the server responds. This is very similar to a regular function call in javascript, except that execution takes place (typically) somewhere else in cyberspace.

With asynchronous behaviour, javascript continues when the request is sent - a response handler having already been established. While the response is awaited, the user is free to carry on interacting with the browser unless html elements (buttons/links) have been specifically disabled (which is often a good idea to prevent potentially confounding AJAX requests being initiated).

"Asynchronous" is used because, when a true AJAX request is pending, the client (javascript and native browser code) and the server (php etc.) are independent of each other. Their behaviour is asynchronous.

Airshow

commented: really good. +2

Thank you so much Airshow. youe explanation is so good. i am very clear now.

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.