2013-10-15 41 views
0

下面的代碼應該是直接不能得到那麼當

//Generic success routine, let the developer know, store the results 
function genericSuccess(_data , textStatus , jqXHR) 
{ 
    data[this.url] = _data; 
} 

jQuery.when( $.ajax({ url: metaKey, success: genericSuccess }) , 
       $.ajax({ url: docsKey, success: genericSuccess })).then(console.log("Then!")); 

console.log('Then')不斷第一觸發之後觸發。爲什麼?這不適用於1.7.2和1.8.3

回答

2

您沒有將回調傳遞給.then,而是您只是console.logging 「那麼!」立即致電

你想要的是:

.then(function(){ 
    console.log("Then!"); 
});