Asynchronously Delay JS Until A Condition Is Met


Answer :

Consider this:

(function wait() {     if ( chatroom.json ) {         chatroom.render();     } else {         setTimeout( wait, 500 );     } })(); 

This will check every half second.

Live demo: http://jsfiddle.net/kBgTx/


Comments

Popular posts from this blog

Chrome Ipad Extensions Code Example

AngularJS $on Event Handler Trigger Order