문제

The following code should be straightforward

//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!" ) );

But console.log('Then') keeps triggering first. Why ? This does not work with 1.7.2 and 1.8.3

도움이 되었습니까?

해결책

You aren't passing a callback to .then, instead you're just console.logging "Then!" immediately.

What you want is:

.then( function(){
    console.log( "Then!" );
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top