[英]Continue function after ajax request has been completed
我想知道是否有可能調用一個具有ajax請求的函數,並在ajax請求完成后繼續執行。 這是示例偽代碼。
function func1(){
//do things
func2();
//**How would I get this code to execute after the ajax request is finished.
}
function func2(){
$.ajax({
url: "test.html",
context: document.body,
success: function(){
//do some things
}
});
我不想在回調函數中執行所有操作,因為該函數在循環中被多次調用。
謝謝!
您有兩種選擇。
否則,就沒有完成您所描述內容的好方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.