Updating without overloading the page



  • The challenge is:

    if($Num == 2){
    echo 'ОК';
    }else{
        echo 'Если значение $Num не ровняется 2, то необходимо обновить страницу и заного выполнить скрипт.';
    }
    

    The violin must be performed again and again until the condition works. if($Num == 2)I'm getting it from a database request. Now, when it works. else There's just a quick recalculation on this page, and that's how the page goes until the number two comes from the base. It's all beautiful.

    But I would like to make sure that the violin is updated without rebooting the sketch, and it is desirable that a picture of the animation of the loading lane should be found on the page at the time the meaning and updates are searched. And when the number two is there, it was only then that condition came out.

    How do you do that? Which way? Thank you.



  •         if ($num!=2){
         ?>
            <script>
            function check(){
                $.ajax({
                    url: 'file.php', //В этом файле делаете запрос в БД и возвращаете результат
                    type: 'POST',
                    dataType: "json",
                    success: function (data) {
                        if (data.num!=2){
                            check();
                        }else{
                            alert('OK');
                            return 0;
                        }
                    }
                });
            }
            </script>
            <?php 
        }
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2