Jump to content

Refreshing page when database updates...


RIRedinPA

Recommended Posts

Browsers, no matter how hard you try, can only function as the client in a HTTP request/response client-server arrangement - http://en.wikipedia.org/wiki/HTTP

 

You need to cause the client (browser) to make periodic http requests to the server in order to get the current information. If you use AJAX, you can then update the information on the page without refreshing the whole page or needing to send all the content that makes up the page (only the changed information needs to be sent.)

 

The database server and the web server cannot actually cause anything to happen on a web page that has been rendered in a browser when an action or event occurs in the database, even if you have a database that supports doing something when an action or event is triggered in the database.

Thanks, I should have provided more details...

 

I have an AppleScript that idles (think cron) every minute and checks to see if iTunes has changed songs, if so it then updates a small database I have with the artist, song title and album, this database is being read and displayed from a PHP page. On that page I'd like to either have it change the displayed data when the db is updated or do something similar to cron/idle and read and display the db data on some sort of timed loop (say also every minute).

Browsers, no matter how hard you try, can only function as the client in a HTTP request/response client-server arrangement - http://en.wikipedia.org/wiki/HTTP

 

You need to cause the client (browser) to make periodic http requests to the server in order to get the current information. If you use AJAX, you can then update the information on the page without refreshing the whole page or needing to send all the content that makes up the page (only the changed information needs to be sent.)

 

The database server and the web server cannot actually cause anything to happen on a web page that has been rendered in a browser when an action or event occurs in the database, even if you have a database that supports doing something when an action or event is triggered in the database.

 

Thanks, that's kind of where I was thinking (see my other, more detailed post) but I'm not aware of anything in PHP that would allow me to do a timed loop such as you can do in AppleScript.

 

Would a Javascript like this work?

 

window.onload = timerMethod;

 

function timerMethod() {

 

    clearInterval(timerId);

    //AJAX stuff here

}

 

var timerId = setInterval(timerMethod, 60000);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.