how to block on ajax call (I want it to block)

后端 未结 1 973
情话喂你
情话喂你 2021-01-05 03:44

Ajax uses callbacks, as it\'s Asynchronous.

I want my call to the remote URL block until there\'s some answer, exactly as in Ajax, but

相关标签:
1条回答
  • 2021-01-05 03:59

    You can simply set the async : false boolean when using jQuery (check the docs). Take note: As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the complete/success/error callbacks.

    If you don't want to use jQuery or want to know what's going on under the hood, read this.

    xmlhttp.open("GET","ajax_info.txt",false);
    xmlhttp.send();
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    

    Do wonder why you don't want it to be async though...

    0 讨论(0)
提交回复
热议问题