Reload AJAX data every X minutes/seconds, jQuery
Posted
by NightMICU
on Stack Overflow
See other posts from Stack Overflow
or by NightMICU
Published on 2010-05-21T12:19:10Z
Indexed on
2010/05/21
12:20 UTC
Read the original article
Hit count: 220
Hi everyone,
I programmed a CMS that has a log of who has recently logged into the system. Presently, this data is fed into a jQuery UI tab via Ajax. I would like to put this information into a sidebar on the main page and load it via AJAX every 30 seconds (or some set period of time).
How would I go about doing this? Does the PHP response need to be JSON coded? I am fairly new to AJAX and JSON data.
Here is the PHP I am currently using to pull details from the users table-
<?php
$loginLog = $db->query("SELECT name_f, name_l, DATE_FORMAT(lastLogin, '%a, %b %D, %Y %h:%i %p') AS lastLogin FROM user_control ORDER BY lastLogin ASC LIMIT 10");
while ($recentLogin = $loginLog->fetch()) {
echo $recentLogin['name_f'] . " " . $recentLogin['name_l'] . " - " . $recentLogin['lastLogin'];
}
?>
Thanks!
© Stack Overflow or respective owner