Can a synchronous (blocking) ajax call block the browser user interface?

This question is focused on jQuery, but not necessarily exclusively.

Short question:

Can ajax synchronous call block a regular button when pressed? My testimony shows that this is not happening, but maybe another browser is causing problems.

Long question:

In another question that I asked how to block the ajax call (I want to block it) , the guys said that the browser will block in some cases.

In fact, even docs jQuery says: Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.

I'm trying to:
1. Understand how and why this will happen.
2. Rate the likelihood of this.

From my understanding, which may be wrong:
I believe that the “blocking” will occur with the user interface of the page if I, as a developer, did not create / update the user interface before the ajax call itself, which “blocks” the javascript virtual machine, thereby delaying the assembly / updating of the user interface. Right or wrong?

+1
source share
1 answer

Yes it will. While the synchronous request is inactive, the browser waits for it to return. The probability of this event is 100%, but if your request is fast enough, it may not be so noticeable. The fact is that you cannot count on a quick return of the request.

What the ajax point invokes. The first a means asynchronous, which means it’s not blocking.

Since ajax calls are asynchronous, your code can be anywhere when the request returns, which means you need a way to handle the response when the request returns. This is why you use callbacks to handle the response.

Why don't you give it a try?

+3
source

All Articles