This could be accomplished using a synchronous xmlhttp call (does jQuery even support this?), or you could put a while loop before the return true to poll a variable that is set in the callback. You would probably want to set the variable if there is an error as well so that the browser doesn't freeze too long.
On Jan 28, 10:33 am, Adam <apcau...@gmail.com> wrote: > How can I wait for the load() function to finish before executing the > next line of code? The code that I need to execute after load() is > finished cannot be called within the callback function. I basically > need to return true after the load has finished but not beforehand. > > Here's the relevant code: > > jQuery(this).cluetip({ > cluetipClass: 'jtip', > arrows: true, > dropShadow: false, > hoverIntent: false, > sticky: true, > mouseOutClose: false, > closePosition: 'title', > closeText: 'close', > activation: 'click', > local: true, > hideLocal: true, > onActivate: function() { > var url = > jQuery(this).attr("href"); > jQuery(this).load(url); > > //dont' return true > until load() is finished > return true; > } > });