Jump to content


Photo

Auto reloading script


  • Please log in to reply
5 replies to this topic

#1 TheUkSniper

TheUkSniper
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 03 April 2006 - 09:58 PM

i have got a php script i want to reload every 5 seconds when someone is on it... i currently have it in a hidden IFRAME but on each refresh u get tht clicking noise... is there anyway to either stop the clicking noise or to get php to reload without taking the user refreshing the page they are on (dont think this is possible)
thanks :)

#2 DrDre

DrDre
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 03 April 2006 - 10:01 PM

[!--quoteo(post=361366:date=Apr 3 2006, 05:58 PM:name=TheUkSniper)--][div class=\'quotetop\']QUOTE(TheUkSniper @ Apr 3 2006, 05:58 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
i have got a php script i want to reload every 5 seconds when someone is on it... i currently have it in a hidden IFRAME but on each refresh u get tht clicking noise... is there anyway to either stop the clicking noise or to get php to reload without taking the user refreshing the page they are on (dont think this is possible)
thanks :)
[/quote]
[a href=\"http://w3schools.com/ajax/default.asp\" target=\"_blank\"]http://w3schools.com/ajax/default.asp[/a]

Thatll do exactly as you want.


[a href="http://forums.fanetworks.net" target="_blank"][/a]
» faNetworks Webmaster. [[a href="http://fanetworks.net" target="_blank"]fanetworks.net[/a]]
» faSoftware Developer [[a href="http://software.fanetworks.net" target="_blank"]software.fanetworks.net[/a]]
» faForums - php Resource + more [[a href="http://forums.fanetworks.net" target="_blank"]forums.fanetworks.net[/a]]
» Experienced php Coder - Ill help anyone I can if I have time ;)

#3 TheUkSniper

TheUkSniper
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 03 April 2006 - 10:48 PM

got the ebook on learning ajax.. not read it yet tho but im not sure tht ajax can refresh results on a time limit

#4 Guest_footballkid4_*

Guest_footballkid4_*
  • Guests

Posted 04 April 2006 - 12:09 AM

The benefit of using AJAX is to send a request to the page to see if the data has changed at all. If the data has changed, then you can reload the page...otherwise you don't reload it. Then you don't have the page reloading every 5 seconds...only when the data has changed.

#5 DrDre

DrDre
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 04 April 2006 - 12:11 AM

<script>
function Update() {
  //your ajax code
  setTimeout("Update()",5000);
}
Update();
</script>

That will make it Update every 5 seconds.
[a href="http://forums.fanetworks.net" target="_blank"][/a]
» faNetworks Webmaster. [[a href="http://fanetworks.net" target="_blank"]fanetworks.net[/a]]
» faSoftware Developer [[a href="http://software.fanetworks.net" target="_blank"]software.fanetworks.net[/a]]
» faForums - php Resource + more [[a href="http://forums.fanetworks.net" target="_blank"]forums.fanetworks.net[/a]]
» Experienced php Coder - Ill help anyone I can if I have time ;)

#6 TheUkSniper

TheUkSniper
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 05 April 2006 - 07:42 PM

currently i got this

Page2.php - this is the main page and has the iframe for Page3.php

Page3.php - autorefreshes every 5 seconds, looks up the database and checks whether the database says the pages is locked (0) or open (1). If its locked, it will take over Page2.php via js changing the page to Lock.php


how would i go about doing this with AJAX... am i right by thinking i need to create a php file that checks the database to see if the page is locked and echo's either 1 or 0... then the Page2.php must contain some AJAX script to read the php file and then will change the pages location if the php file echos 0... if it is.. any one got any idea where to find some AJAX code to do this cus the parts i found just use text and html files

thanx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users