【问题标题】:Cant get then to trigger after when无法在何时触发
【发布时间】:2013-10-23 19:14:07
【问题描述】:

下面的代码应该很简单

//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

【问题讨论】:

    标签: jquery promise .when


    【解决方案1】:

    您没有将回调传递给.then,而是立即进行控制台记录“那么!”

    你想要的是:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-17
      • 1970-01-01
      • 1970-01-01
      • 2018-05-24
      • 1970-01-01
      • 1970-01-01
      • 2013-01-31
      • 2016-10-18
      相关资源
      最近更新 更多