//Interval will run/tick every second until 'variable' is set to something (defined)
var interval = setInterval(function() {
console.log('Interval Running');
if( variable == "undefined" || variable == ""){
//Do Something While Waiting / Spinner Gif etc.
}else{
console.log('Interval Stopped');
clearInterval(interval);
}
}, 1000);