考虑下面的代码:
function doSomething() {
var promise = $.ajax(//...);
return promise;
}
让我们一起使用它
then
:
doSomething().then(function(data) {
return true; // this is passed to the next then
}).then(function(data){
alert(data); // this will show true as expected
return doSomething(); // A promise object should be passed to the next then
}).then(function(data){
// I expected this to be the promise object but this is not a promise object.
// It is the response from the doSomething() AJAX call
alert(data);
});
问题
当前位置最后一个问题是什么
data
参数是否包含响应?这是怎么回事?