I'm building a forum and I use this code to load all the comments forum_retrieve.php
and this works fine at this point.
$(document).ready(function() {
$('#results_holder').load('forum_retrieve.php<? echo ' ? forum_id = ' . urlencode($forum_id) ?>').show();
});
But when a user submits the form to forum_handle.php
(to save the comment to sql) and gets redirected back using:
if ($connect->query($sql) === TRUE) {
header('Location: forums.php?id=' . $_POST['forum_id']);
} else {
the Ajax wont load the new results, even if I submit 5 comments, they wont load until I refresh the page or click on another page and come back.
I have even tried putting the ajax on a time delay of 30 seconds and it still wont load the new results even though I can see it in sql before the timer is up.
I have tried using no caching headers
. I have also tried $(window).ready
.
Shouldn't a new query be made every time the document is loaded?I don't get why its choosing not to. Any suggestion will be greatly appreciated.