Go Back   HTMLCenter Web Development Forums > Web Design and Development > Programming and Scripting

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 08-05-2008, 03:20 PM
Leprakawn's Avatar
Moderator
 
Join Date: Jan 2004
Location: Outside, and playing with your invisible friends.
Posts: 1,110
Send a message via AIM to Leprakawn Send a message via Yahoo to Leprakawn
Server-side reload

I remember looking this up long ago and not finding anything very helpful with it... so here I am with this mssg.

There is an example on this page of why I am asking this question. If you look to the bottom, you will see the 24hr grid of gold's price. It is current, but if you sit there for five minutes it does not change, whereas the content will be updated if you reload the page. Is there a way to create a server-side reload (like every minute or two) to update the img? I know it might take an iframe to get that to work so not everything reloads... but I want to see if that is possible.

And if this can work, would it require PHP?

Thanks!
__________________
Like my spiffy, unique signature?
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote

  #2 (permalink)  
Old 08-05-2008, 07:17 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,396
Unfortunately, I cannot imagine any server-side script being able to do a timed reload; as, once a server-side script is executed, it is abandoned.

Is there any particular reason you are averse to using javascript to reload the image? You could easily build a timer that would reload the image every ___ seconds (or minutes, or however long you choose).

Your code could look something like:
Code:
<img src="http://www.kitco.com/images/live/gold.gif" id="goldchart" alt="Gold price chart" />
<script type="text/javascript" language="javascript">
// Create a function to change our picture
function changepic() {
// Instantiate a new date object, so we can get our timestamp
var d = new Date();
// Create a new image in the DOM
var i = document.createElement('img');
var j = document.getElementById('goldchart');
// Assign our source to the new image. We are going to append a nonsense query string, based on the current timestamp, to our image URI, in order to keep it from getting cached
i.src = "http://www.kitco.com/images/live/gold.gif?"+d.getTime();
// Assign the same ID we assigned to our original image
i.id = j.id;
// Assign the same ALT tag we assigned to our original image
i.alt = j.alt;
// Replace our original image with our new image
document.getElementById('goldchart').parentNode.replaceChild(i,document.getElementById('goldchart'));
// Set a timer to execute this function again
t = setTimeout("changepic()",10000); // The timer is currently set to 10,000 milliseconds (or 10 seconds)
}
// Instantiate our timer the first time
var t = setTimeout("changepic()",10000);
</script>
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote
  #3 (permalink)  
Old 08-05-2008, 10:00 PM
Leprakawn's Avatar
Moderator
 
Join Date: Jan 2004
Location: Outside, and playing with your invisible friends.
Posts: 1,110
Send a message via AIM to Leprakawn Send a message via Yahoo to Leprakawn
Thumbs up

Wow, Curtiss... you rock! I will have to test it out to see how that works.

To answer your ?, I kind of figured that it would be stupid to tell the visitors, "Hey, reload this page every few minutes to get updated info." So that got me to thinking about something generated from the server, and the server-side reload came to mind. I know there is a way to do the meta forward function (which could essentially be turned into a reloading function; however, it would effect the whole browser window vs. just the iframed page), but I was unaware of this function.

Thank you so much!
__________________
Like my spiffy, unique signature?
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #4 (permalink)  
Old 08-06-2008, 08:48 AM
Deadeye's Avatar
Moderator
 
Join Date: Aug 2005
Location: San Diego, CA
Posts: 266
Send a message via MSN to Deadeye
while I dont know how to write it, ajax call to the server to reload only that image would work. I think thats what Curtiss is getting at.

Wesley
__________________
Don't forget to rate me A+++++++++++++++++!!!!!111one for the service you have received.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Zip From server.. yuppicide Off-Topic 0 07-01-2008 03:56 PM
Frameset Reload in Mozila Firefox 2 asimqazi Programming and Scripting 3 03-27-2007 07:27 AM
site works on one server – on another not rikardlassenius Programming and Scripting 2 01-18-2007 02:11 AM
Apache error under Win2000 ocoisadificil Servers 0 09-12-2006 08:54 AM
Looking To Set Up A Server curtiss Servers 23 02-15-2005 06:19 PM


All times are GMT -5. The time now is 10:17 PM.

 
KickApps
Clicky Web Analytics


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter