打赏

$.post() 和 $.get() 如何同步请求

由于$.post() 和 $.get() 默认是 异步请求,如果需要同步请求,则可以进行如下使用:

在$.post()前把ajax设置为同步:$.ajaxSettings.async = false;

在$.post()后把ajax改回为异步:$.ajaxSettings.async = true;

如:

    $.ajaxSettings.async = false;
    $.post("/finance/getLastTimeCard", data, function(result) {
        // 请求处理
    },"json");
    $.ajaxSettings.async = true;

 

 

 


原文:https://blog.csdn.net/sunnyzyq/article/details/78730894

posted on 2018-12-20 14:03  头大的冯冯  阅读(135)  评论(0编辑  收藏  举报

导航