这是我的 jQuery 代码
$.ajax({
method: "POST",
url: base_url + "/stats/add.json",
data: JSON.stringify(data_stat) ,
contentType: "application/json",
success: function(msg){
alert(msg.message);
}
});
alert("other");
仅在出现alert("other")
时才发布数据。
最佳答案
但是如果您想明确提醒您的消息,可以在 .done()
中完成,而不会阻塞主 UI
$.ajax({
method: "POST",
url: base_url + "/stats/add.json",
data: JSON.stringify(data_stat) ,
contentType: "application/json",
success: function(msg){
//Blocks main UI because of the reason Rocy McCrossan told you
alert(msg.message);
},
}).done(function(msg) {
alert(msg.message);
});
关于javascript - $.ajax 函数未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36031247/