I\'m trying to refresh my recent list every 5 seconds. I was looking at ajax and found jquery.
I found a function known as \"everyTime\"
This is what I have
5s
is neither an integer or a string, and so it's an invalid input. To achieve the desired behavior you can use an integer number of milliseconds:
$(document).everyTime(5000, function(i) {
<?php include "recent.php";?>
}, 0);
or a string indicating the interval:
$(document).everyTime('5s', function(i) {
<?php include "recent.php";?>
}, 0);
(here's a reference)
everyTime seems to be a jQuery plugin that has a lot of functionality you're not using here. For what you're doing, you can just use setInterval
thus:
setInterval(function() {
// refresh list
}, 5000)
where the second parameter is the number of milliseconds.
Note on everyTime
If you really want to use everyTime, you'll need to make your first parameter a string, that is:
$(document).everyTime("5s", function(i) { }, 0);
Note the quotes around the 5s. You'll also need to include the appropriate javascript file for the plugin (not just for jQuery) at the top, i.e.
<script type="text/javascript" src="/js/jquery.timers.js"></script>
You can use everyTime plugin with jQuery Ajax like this:
var j = jQuery.noConflict();
j(document).ready(function()
{
j(".refresh").everyTime(1000,function(i){
j.ajax({
url: "refresh.php",
cache: false,
success: function(html){
j(".refresh").html(html);
}
})
})
});
Late answer. Hope this will help users researching on similar functions.