1

I need to auto refresh the content of a page once a form has been submitted. The content is a search for hashtags and it needs it to update every x seconds. The bit I am struggling with is, is my form submits to itself so everything is handled on the same page. So I need to preserve the users search string when the content is refreshed so it displays the results and any new ones that been found.

Pretty much the same in principle as http://gigatweeter.com/

This is the code I have been using.

<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#load_page').load('twitter.php').fadeIn("slow");
}, 10000); // will auto refresh every 10 seconds
</script>

I cant find any support or threads into how to do this if the the page submits to itself so any help would be appreciated.

Could I call the php at the top of the page to start again perhaps?

user1711576
  • 402
  • 8
  • 24
  • 2
    It would be a lot easier for you to just make a separate php script that returns only what you need. – Asad Saeeduddin Oct 25 '12 at 13:28
  • I did originally but I needed it to display results on the same page as the query was submitted on and I dont know how to do that tbh – user1711576 Oct 25 '12 at 13:30
  • You are using ajax, right? Write a script that generates the appropriate content for the load_page div and just change `twitter.php` to the address of that script. – Asad Saeeduddin Oct 25 '12 at 13:34
  • Im using the AJAX for the refresher and php for everything else. how would I get it to return the data to the page? – user1711576 Oct 25 '12 at 13:40
  • Ok again, make a php file called say, `twitfeed.php`. Inside it, write php that generates and outputs the html content you want in `#load_page`. Then change your js to `$('#load_page').load('twitfeed.php').fadeIn("slow");` and you're done. – Asad Saeeduddin Oct 25 '12 at 13:44
  • have you heard about comet programming it will help you in this situation – Rajat Modi Oct 25 '12 at 13:56
  • I tried this but I cannot get the data to return to the original page and be displayed. Tips? – user1711576 Oct 25 '12 at 23:57

0 Answers0