Why does AJAX allow synchronization?

3

Hello, in my studies on AJAX, the form of synchronous transmission is always viewed with bad eyes, and the widely recommended form of transmission is asynchronous. If only asynchronous is the one we should use, can anyone explain in what situation I will have to use AJAX synchronously? Improving the question: when will the synchronous form have real importance of use? Thank you.

    
asked by anonymous 20.04.2016 / 04:45

1 answer

4

The problem with synchronous requests is that the application becomes paralyzed and dependent on something external to work.

In case the server, or the internet connection has problems and the response does not reach the application is blocked, nothing happens. Not even a setTimeout to reset ajax ... nothing. This is very bad and so this possibility of the JavaScript world is being removed.

Still there were those who mentioned in 2010 that it is good to use this technique as a last resort for onbeforeunload , ie when the user closes the browser and the application needs to communicate with the server. But even here is a bad idea. Incidentally via jQuery is no longer possible in the new versions, this is deprecated. The xhr specifications and the # go in that direction too.

    
20.04.2016 / 07:08