Jump to content

Contiuous Refresh


almightyegg

Recommended Posts

I waswondering how I would make a certain part of the page update every second, to check whether new messages are in the database. I know how I can post messages to the database without refreshing, but it's just showing them afterwards without a page reload that I can't do. Can anyone point me to a tutorial or help with it temselves? TY in advance :D

Link to comment
Share on other sites

Probably the only way of doing this is using the Javascript to run a function every 1sec, then have the JS function use ajax to call a php file which you can check to see if there is any new update. Then load whatever you found into a div or span tag on your page.

 

JS file

function checkMessages(){

sendRequest('checkNewMessages.php','newMessages');

setTimeout("checkMessages", 1000);
// Param 1 = "checkMessages" will call this function
// Param 2 = 1000 milli = 1 sec
}

 

PHP FILE

do whatever you need to do

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.