buildMyUrl 的结果在调用函数中始终未定义。我不确定链接这些函数我做错了什么:
var buildMyUrl = function (callback)
{
var param;
var addParams = function (domainUrl)
{
domainUrl += "page.aspx?";
domainUrl += "Param1=";
};
$.when(self.buildDomainUrl()).then(addParams);
};
buildDomainUrl
返回一个 JQuery 承诺并添加参数工作正常。现在我有一个想要使用结果的函数buildMyUrl
:
var buildAPageUrl = function ()
{
var dfd = $.Deferred();
var addCalendarPage = function (domainUrl)
{
dfd.resolve(domainUrl += "/Calendar.aspx?");
};
// Here lies the problem (buildMyUrl is undefined)
$.when(buildMyUrl()).then(addCalendarPage);
return dfd.promise();
}