Merging $.get and $.ready
- by cwolves
Put simply I have an ajax call that sometimes completes before the page is loaded, so I tried wrapping the callback in $( fn ), but the callback doesn't fire if the page is loaded... Anyone have a good solution to this?
$.get( '/foo.json', function( data ){
$( function(){
// won't get here if page ready beats the ajax call
// process data
$( '.someDiv' ).append( someData );
} );
} );
And yes, I know that if I flipped the order of those it would always work, but then my ajax calls would be needlessly deferred until the document is ready.