I have followed all the advice I found here at Wait until all jQuery Ajax requests are done? but I must be missing something basic.
I have this function...
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);
}
}
}
});
}
It is called from the document.ready function of my code and works perfectly, returning the data and displaying it as expected. I want another function to run AFTER ListScores() has displayed its data so, elsewhere in the document.ready function I put...
$.when(ListScores()).done(function(a1){
console.log("hello",leaguex,nameid, a1);
});
... but nothing ever shows up in the console log so it looks like this function is never being called. Am I missing something obvious here?
Thanks Steve