javascript - Reloading a page include every 30 seconds or when user submits form -
i have php page lot of includes make various parts of page video website.
i have comments section submits information database (which works fine). need make when done included page/div refreshes.
this php:
<form id="song-comment-form"> <input type="hidden" value="<?=$rsong->id?>" class="song-id"> <textarea class="editor" id="song-comment-textarea"></textarea><br> <input type="submit" value="submit"><input type="button" value="cancel" id="hide-song-comment-form"> <hr> </form> <div id="player-song-comments"> <?php $showcomments?> </div>
here attempt @ doing javascript:
<script> var $comments = $("#player-song-comments"); setinterval(function () { $comments.load("/template/sections/player_comments.php #player-song-comments"); }, 30000); </script>
this should reload comments section instead, point onwards goes blank.
how looks when press submit:
when reload page manually:
i don't want whole page refresh because contains video.
how can make refresh after submit pressed or every 30 seconds?
update: have tried using jquery execute this. i'm getting error:
fatal error: call member function query() on non-object in /home/content/58/12052758/html/template/sections/header.php on line 42
<script> /*wait dom loaded $(document).ready(function() { // bind 'myform' , provide simple callback function $('#song-comment-form').ajaxform(function() { alert("thank comment!"); }); }); */ //this line 42 $(document).ready(function() { var options = { url: 'template/sections/player_comments', target: '#player-song-comments', // target element(s) updated server response type: 'post' // 'get' or 'post', override form's 'method' attribute }; // bind form using 'ajaxform' $('#song-comment-form').ajaxform(options); $(document).ready(function() { // bind 'myform' , provide simple callback function $('#song-comment-form').ajaxform(function() { $("#player-song-comments").load('template/sections/player_comments.php'); alert("thank comment! site in maintenance , comment won't show until revisit video"); }); }); }); </script>
for interested. here whole page: http://pastebin.com/c0kq3tgp
you seems load comments in php , far know, php parsed once.
the simplest workaround know use iframe refresh, i'm not sure practice tho.
Comments
Post a Comment