How {async:false} works in jQuery AJAX request?

后端 未结 2 854
感动是毒
感动是毒 2021-01-20 21:07

I know why and how to use {async:false} in jQuery AJAX request.

But what I need is how this works synchronously? What is the magic behind this?

2条回答
  •  遇见更好的自我
    2021-01-20 21:35

    Because the native XMLHTTPRequest object provides the possibility to make synchronous requests:

    async
    An optional boolean parameter, defaulting to true, indicating whether or not to perform the operation asynchronously.

    You can assume that it does that by pausing the thread in which JS runs.

提交回复
热议问题