javascript - How do you make an event listener that detects if a boolean variable becomes true? -


for example, have var menu_ready = false;. have ajax function sets menu_ready true when ajax stuff done:

//set event listener here  $(...).load(..., function() {     ...     menu_ready = true; } 

how set event listener waits menu_ready true?

one way continual polling:

function checkmenu() {     if (!menu_ready) {         settimeout("checkmenu();", 1000);         return;     } else {         // menu_ready true, need here.     } } 

and...

<body onload="checkmenu();"> 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -