I am wondering about the behavior of the code below. Ajax.chan(tid)
is the ajax call found below. The other three functions are not Ajax related. When I don't pass a parameter to Display.channelLoad
, the code works as expected and these functions run after the ajax is complete. But if I change that to .done(Display.channelLoad())
, this function runs before the ajax call is complete. This is probably some basic javascript knowledge that I am missing, but I would like to pass a parameter to Display.channelLoad
and understand what is occurring here.
AjaxCall.chan(tid).done(List.articles)
.done(Display.channelLoad)
.done(Display.unblockUI);
AjaxCall.chan()
var AjaxCall = {
chan: function(tid) {
return getArticles = $.ajax({
url: "http://ainonline.com/api/channel/" + tid,
context: document.body,
dataType: 'jsonp'
});
}
Thank you.