post/get tip in "async method"

reference this:

https://stackoverflow.com/questions/133310/how-can-i-get-jquery-to-perform-a-synchronous-rather-than-asynchronous-ajax-re

 

function submitMe(url, data) {
    //get{name:aa,old:17}
    //post/get,return true false
    //$.get can't be used here, "async false" ensure that getting the codeValue correctly.
    var codeValue;
    $.ajax({
        url: url, data: data, success: function (obj) {
            console.log(obj.code == "0");
            if (obj.code != "0")
                stateText(obj.msg);
            codeValue = obj.code == "0";
        }, async: false
    });
    return codeValue;
}

 

posted on 2017-10-16 16:19  鸣动我心  阅读(133)  评论(0编辑  收藏  举报