close
轉自 http://www.phpernote.com/jquery/312.html
--
當需要使用ajax呼叫,但一定要等到ajax程式執行完才能繼續往下跑的時候會用到。
重點是在jQuery ajax加上"async: false,"參數(非同步: 關閉)
--
Jquery等待ajax執行完畢再繼續執行下面代碼的效果,具體代碼如下,其實就是將jquery ajax 函數的async 參數設置為false 即可,該參數默認為true:
$(document).ready(function(){
loadphpernote();
window.open('http://www.phpernote.com');
});
function loadphpernote(){
var url='http://www.phpernote.com/ajax.php';
var data='action=list';
jQuery.ajax({
type:'post',
url:url,
data:para,
async:false,//false代表只有在等待ajax执行完毕后才执行window.open('http://www.phpernote.com')语句
success:function (msg){
$('#articleList').html(msg);
}
});
}
--
全站熱搜