0

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.

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by yaragalla_mural
0

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.

0

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?

Edited by yaragalla_mural: n/a

0

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?

0

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.)

3

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

Votes + Comments
really good.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.