I'm trying to load 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 isn't loading anything. What am I doing wrong?
SOLVED! I suddenly forgot to include jQuery. I'm facedesking now! :D
Try this and have a look at the developer JavaScript console (press F12 in Chrome/Chromium) and see if the word "invoked" or any error messages happen:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With