Это мой код:
var b;
while(!b){
setTimeout(function(){
alert('sss')
b=1;
}, 500);
}
и он не будет предупреждать 'sss'
Что я могу сделать?
Обновлен:
Я хочу получить границы на картах Google v3:
function get_bounds(){
var bounds_;
while(!bounds_){
setTimeout(function(){
bounds_=map.getBounds();
if(bounds_){
var leftBottom=[bounds_.getSouthWest().lat(),bounds_.getSouthWest().lng()]
var rightTop=[bounds_.getNorthEast().lat(),bounds_.getNorthEast().lng()]
return [leftBottom,rightTop];
}
}, 500);
}
}
updated2:
привет, Патрик Д.В., я не знаю почему, но ваш код не работает:
var b;
function waitForB() {
setTimeout(function(){
if(!b)
waitForB();
else
alert('sss');
}, 500);
}
waitForB()
updated3:
теперь все в порядке:
var b;
function waitForB() {
setTimeout(function(){
if(!b){
waitForB();
b='ss';
}
else{
alert('sss')
}
}, 500);
}
waitForB()