AJAX .post async

和自甴很熟 提交于 2019-12-22 10:32:19

问题


What exactly does the following do:

$.ajax({
     type: "POST",
     async: false,

vs

$.ajax({
    type: "POST",
    async: true,

Meaning what is the difference in the behavior?


回答1:


From the jQuery site:

By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.

That's all there is to it. If you need help on a specific problem let me know.




回答2:


The async call not "break" execution of javascript code. Need callback's function for when return of request from server delivery. It is more complicate to development and need more control of your´s functions.



来源:https://stackoverflow.com/questions/10802156/ajax-post-async

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!