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

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?