【发布时间】:2018-11-19 13:20:00
【问题描述】:
我现在正在苦苦挣扎两天,试图将带有 async:false 的简单 AJAX 函数转换为一个不错的 jQuery Deferred() 函数。我试图返回 AJAX 响应的一切都不起作用:-(
这是我的旧(短)代码版本:
function uiText($textID) {
var text = $.ajax({
url: "uitext.php",
async: false,
success: function(response){}
};
return text.response;
}
console.log(uiText('foo')); //shows me the response from uitext.php
我如何使用 $.Deferred 和/或 $.when().done() 来做到这一点
谢谢迈克
【问题讨论】:
标签: javascript jquery ajax jquery-deferred