I have a function which look so:
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();
}
And the call to that function is:
get_modifications_as_objects()
.then(function(lov_values_object) {
console.log(lov_values_object);
});
Of course, in this case, ".then" isn't working because it never gets to the return of my promise. So I tried to wrap the two returns into separate functions but I couldn't make it work.
I need to return both the promise and the other object, how can I do?
pass data using deferred.resolve()
method
var deferred = $.Deferred();
//Do stuff.....
deferred.resolve({
actual_lov_values: actual_lov_values,
new_lov_values: new_lov_values,
deleted_lov_values: deleted_lov_values
});
return deferred.promise();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.