How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

后端 未结 14 2296
暗喜
暗喜 2020-11-21 05:07

I have a JavaScript widget which provides standard extension points. One of them is the beforecreate function. It should return false to prevent an

14条回答
  •  长情又很酷
    2020-11-21 05:49

    Since the original question was about jQuery.get, it is worth mentioning here that (as mentioned here) one could use async: false in a $.get() but ideally avoid it since asynchronous XMLHTTPRequest is deprecated (and the browser may give a warning):

    $.get({
      url: url,// mandatory
      data: data,
      success: success,
      dataType: dataType,
      async:false // to make it synchronous
    });
    

提交回复
热议问题