我遵循了我在这里找到的所有建议,直到完成所有jQueryAjax请求,但我一定是错过了一些基本的东西......
我有以下功能:
function ListScores(leaguex, nameid) {
return $.ajax({
url: 'sg_ajaxListData.php',
data: {
nme: nameid,
league: leaguex
},
dataType: 'json',
success: function (rows) {
for (var i in rows) {
var row = rows[i];
var score1 = row["score1"];
var score2 = row["score2"];
var round = row["round"];
$('#output').append("<br />Round " + round + " - " + score1);
if (leaguex == 'r') {
$('#output').append(" " + score2);
}
}
}
});
}
它是从我代码中的document.ready函数中调用的,运行得非常完美,返回数据并按预期显示。我希望在ListScores()显示了它的数据之后再运行另一个函数,因此,在document.readyfunction中的其他地方,我放置了:
$.when(ListScores()).done(function(a1){
console.log("hello",leaguex,nameid, a1);
});
但是控制台日志中没有显示任何内容,该函数似乎从未被调用过。我是不是漏掉了什么明显的东西?
谢谢帮助!