【发布时间】:2017-05-12 08:45:00
【问题描述】:
我有一个看起来像这样的函数:
function get_modifications_as_objects() {
var deferred = $.Deferred();
//Do stuff.....
return {
actual_lov_values : actual_lov_values,
new_lov_values : new_lov_values,
deleted_lov_values : deleted_lov_values
}
deferred.resolve();
return deferred.promise();
}
对该函数的调用是:
get_modifications_as_objects()
.then(function(lov_values_object) {
console.log(lov_values_object);
});
当然,在这种情况下,“.then”是行不通的,因为它永远无法兑现我的承诺。 因此,我尝试将两个返回值包装到单独的函数中,但无法使其工作。
我需要同时返回 promise 和另一个对象,我该怎么做?
【问题讨论】:
标签: javascript jquery promise jquery-deferred