Consider the following code:
var d1=$.Deferred();
var d2=$.Deferred();
d1.resolve();
d2.reject();
var p1=d1.promise();
var p2=d2.promise();
p1.then(function () {
console.log('promiseOne resolved');
return p2;
}).then(function () {
console.log('promiseTwo resolved');
}, function() {
console.log('promiseTwo rejected'); });
where I am getting the results:
promiseOne resolved
promiseTwo rejected
My query is which promise do we have as caller object for the second .then method? To be more specific; if we had:
var x=p1.then(function () {
console.log('promiseOne resolved');
return p2;
})
it is that x!=p2
and that because .then returns a new jQuery.Deferred().promise()
object. However, in which way p2 affects x? Does the new promise x gets only the value of p2.state()?