Похоже, что мой скрипт не хочет ждать завершения вызова $ .post.Это проблема.Вот некоторый псевдокод:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
// Global var, to be used everywhere in the ready scope
// Note its default value!
var test = false;
$.post('test.php',{},function(result){
if(result=='yes')
{
// This gets executed!
alert('Its true! Hurraaay!');
test = true;
}
else
{
test = false;
}
}
if(test==false)
{
// THIS gets executed, despite the fact that we set test to true!
alert('Awww....');
}
// it reaches this, showing us that there was no error!
alert('Im alive!!!');
// and a whoooole bunch of other code here...
}
</script>
Каков наилучший способ убедиться, что мой вызов Post завершен перед продолжением, без зависания браузера?Надеясь на то, что не слишком грязно.:)