Download code from .php file every few seconds

I try to download code from sadrzaj.php every 3 seconds. This is my code:

<body onload="ima_sta_novo()">
<div id="sadrzaj">
</body>

<script type="text/javascript">
    function ima_sta_novo(){
        $('#sadrzaj').load('sadrzaj.php');

    }
    setInterval(function(){ima_sta_novo()}, 3000);

</script>

But it does not load anything. What am I doing wrong?

SOLVE! I suddenly forgot to enable jQuery. I'm watching now !: D

+3
source share
6 answers

Try this and look at the developerโ€™s JavaScript console (press F12 in Chrome / Chromium) and see if the word "is called" or any error messages:

 <html>
    <head>
        <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    </head>
    <body>
        <div id="sadrzaj"></div>

        <script>

            function setTimer() {
                setInterval(function(){
                    console.log('invoked');
                    $('#sadrzaj').load('sadrzaj.php');

                }, 3000);
            }


            $(document).ready(setTimer);
        </script>
    </body>
</html>
+1
source
 $(document).ready(function () {
             setInterval(function (e) {
             $('#sadrzaj').load('sadrzaj.php');
        }, 1000);
    });
0
source

div end html-,

javascript :

 window.setInterval(function(){
  ima_sta_novo();
}, 3000);

jquery, :

$(document).ready(function()
{
   setInterval( function()
   {
      ima_sta_novo();
   }, 3000);
});
0

javascript

<body onload="ima_sta_novo();">
<div id="sadrzaj">
    </div>
    <script>
         function ima_sta_novo(){
        window.location.href = "sadzraj.php";
    }
    setInterval(function(){ima_sta_novo()}, 3000);

    </script>
</body>
0

div

<div id="sadrzaj"></div>

, .

javascript ima_sta_novo()

0

Replace /fooobar.com / ... with a link to your page

<script type="text/javascript">
    setInterval(function(){window.location.replace("http://qaru.site/")},3000);
</script>

This way you completely reload the page, if you don't mind overloading the page, this is an easy way to go.

-1
source

All Articles