I have a JavaScript function that calls and gets a users cars for there area - it is as below:
function getCars(userId) {
var cars = $.Deferred();
var listOfCars = [];
// Iterate over all areas
$.when.apply($, $.map(areas, function (area) {
return $.when(getCarsForArea(area, userId)).then(function (result) {
$.merge(list, result);
});
})).done(function () {
cars.resolve(list);
});
return cars.promise();
}
I then have another deferred that I want to use passing in the result of the function above.
so like
var userCars = $.Deferred();
var result = getCars('1234'); //User 12345
userCars .resolve(result);
and later I have in a function
$.when(userCars).then(function (carsForUser) {
console.log(carsForUser);
// rest of method removed for brevity
however in my console I am getting jQuery promise objects logged rather that BMW, Mercedes, etc - i.e - the data from the getCars method.
Is there something I am missing in the way I have wired this up?