async:false option not working in $.ajax() , is it depreciated in jQuery 1.8+ for all use cases?

前端 未结 3 633
耶瑟儿~
耶瑟儿~ 2020-12-11 05:26

I\'m confused about using the async: false option with $.ajax(). According to the $.ajax() documentation:

As of jQuery 1.8, the use of async: false w

3条回答
  •  感动是毒
    2020-12-11 06:01

    You trying to use JSONP techinque with async:false at the same time. This is not possible. JSONP is actually creating a script element and appending it somewhere to the document, so it's not an XHR and jQuery can't pass the sync flag anywhere. Since you get data from the same origin, just change dataType to

    dataType:       'json',
    

    However, everyone can tell you that synchronous requests are not good they hang your browser. You should use them only in a small number of cases.

提交回复
热议问题