我想知道有沒有辦法在jQuery中停止代碼執行,直到返回函數結果。在jQuery中暫停代碼執行
functionName() {
//user inserts something
return user_insertion;
}
$(document).ready(function() {
//code before
if (var1.length > 1) result = functionName(data);
else result = [data: 1, data: 2, data: 3];
//code after, the one I want to pause execution of
//do something with result that user inserted
});
*「我想知道有沒有辦法在jQuery的停止代碼執行,直到返回函數的結果。」 * **電話** – 2014-10-09 14:35:38
如果你。閱讀其他問題,他們都應該說你不應該這樣做。 – Barmar 2014-10-09 14:36:13
歡迎使用異步編程。 – Andy 2014-10-09 14:37:51