Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The method Open of XMLHttpRequest

What's the difference between Sync and Async in the method open(method,url,async) in AJAX.

like image 326
Wassim AZIRAR Avatar asked Dec 17 '25 18:12

Wassim AZIRAR


2 Answers

The difference is that Sync doesn't exist. Ignore it. I wrote a whole synchronous widget library five years ago, and I became a better programmer when I rewrote it :-) I mention jQuery in this sentence but my preference goes to YUI. Whatever you do, watch the videos on Yahoo Theater: basic and advanced Javascript, the trouble with Dom, everything. They rock.

like image 121
Marco Mariani Avatar answered Dec 20 '25 20:12

Marco Mariani


If you pass true for the async parameter, the call will return right away and the next line of javascript will execute (before the HTTP request returns).

If you pass false, it will block until the HTTP call returns.

like image 25
pkaeding Avatar answered Dec 20 '25 19:12

pkaeding