php - I can't refresh a div in my web -
i'm trying refresh part of web, div, found code this, doesn't works. seems it's correct doesn't works. don't understand happens, tried other jquery codes , doesn't work too.
this html file:
<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> var timer; var seconds = 1; $( document ).ready(function(){ startactivityrefresh() }); function startactivityrefresh() { timer = setinterval(function() { $('#div1').load('prova.php'); }, seconds*1000) } </script> </head> <body> <div id="div1"></div> </body> </html>
and php file:
<?php echo "prova"; ?>
when go browser , reload page doesn't show anything. should show prova
. (the php file test)
[resolved] problem in browser, firefox blocked content. there shield in url bar unblock it.
as mentioned, never called startactivityrefresh()
try this.
<script> var timer; var seconds = 1; $( document ).ready(function(){ startactivityrefresh() }); function startactivityrefresh() { timer = setinterval(function() { $('#div1').load('prova.php'); }, seconds*1000) } </script>
until called, function hanging out, waiting other piece of code need it.
i should mention there @ least 2 ways call function on page load. $(document).ready
, $(window).onload
. here's discussion on difference.
edit:
here's fiddle demonstrates basic idea.
Comments
Post a Comment