我在ajax代碼中添加了「async:false」,用於遠程函數,但它推動了它之前的所有內容。Ajax函數將所有東西放在一邊
這是代碼怎麼回事:
function load() {
$("#Load").show(0,function(){
console.log('Spinner Loaded');
});
}
function unload() {
$("#Load").hide();
console.log('Load Ended');
}
function server(datasend) {
load();
var response;
$.ajax({
type: 'POST',
url: 'http://mailsnitch.ipx-il.com/get/index.php',
dataType: 'json',
timeout:4000,
async: false,
data: datasend,
success: function(valueable){
console.log('Success');
response = valueable;
console.log(valueable);
},
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error.\n' + jqXHR.responseText);
}
},
});
unload();
return response;
}
林打電話server()
,並且順序應該是:load();$.ajax();unload();
的acctual順序是$.ajax();load();unload();
請幫助:)
THX,阿米特。
如何要檢查順序? –