如何使用;jQuery.when";在jQuery ajax成功回调中?
如何在Ajax成功回调中使用jQuery.when(..).done() Javascript如何使用;jQuery.when";在jQuery ajax成功回调中?,jquery,Jquery,如何在Ajax成功回调中使用jQuery.when(..).done() Javascript button = function () { doPost('sucess.php', 'first=' + first, function (response) { $.when($.ajax("sucess.php")).done(function (a1) { // Stop the button
button = function () {
doPost('sucess.php',
'first=' + first,
function (response) {
$.when($.ajax("sucess.php")).done(function (a1) {
// Stop the button function execution
});
}
);
}
doPost = function (url, data, success, complete, options) {
var defaults = {
url:url,
data:data,
success:success,
complete:complete,
type:'POST',
processData:false
};
if (options) {
for (var i in options) {
defaults[i] = options[i];
}
}
$.ajax(defaults);
}
由于某些原因,上面的代码不起作用。
请检查我的
$语句是否有任何问题。when(..).done()
语句。您可以在任何地方使用jQuery.when;但是,您必须知道如何应用它
到这里:
我在您对zequinha bsb的回复中发现以下错误:
'$.when is not a function'
您使用的是哪个版本的jQuery?最好记住,$.when在jQuery 1.5之前没有引入。我很感激英语可能不是你的第一语言,但你需要问一个问题。Jusnit,看看我编辑的答案,看看它是否能帮助你。我使用了$.when($.ajax(“suces.php”).done(函数(a1){});但是得到一个错误“$.when不是一个函数”,然后我使用jquery nonConflict仍然错误继续。我如何解决这个问题您忘记在success.php.Try$.when($.ajax(“success.php”).done(function(){})。a1是来自success.php的吗?它是
jquery JavaScript库v1.6
。
'$.when is not a function'