I'm trying to call a function, then take the returned variable and display it on the screen within a div. However, in my current format below, the .html() gets executed simultaneously as the postGameStatistics() function. postGameStatistics() is a function that does an ajax post amongst some other actions. Is there a way to chain this?
var fbDiv = "#fb-request-wrapper";
var xp = postGameStatistics(fbDiv, "#loading_fb", "p2", null);
$(fbDiv).html("Congrats! you've just earned " + xp + " XPs.");
$(fbDiv).show();
$(fbDiv).html(...)in thepostGameStatisticscallback. As we don't know howpostGameStatisticsworks, this is all we can say.