Question

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

Était-ce utile?

La solution

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!" );
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top