Jquery function "everyTime"

I try to update my last list every 5 seconds. I looked at ajax and found jquery.

I found a function known as "everyTime"

This is what I have so far, I really don’t know how to make it work ... This does not work: \

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).everyTime(5s, function(i) {
  <?php include "recent.php";?>
}, 0);
</script>
</head>
<body>
<div id="testDiv">
<h2>This is default. Waiting for refresh</h2>
</div>
</body>
+3
source share
3 answers

everyTime seems to be a jQuery plugin that has great functionality that you are not using here. For what you are doing, you can simply use it setIntervalthis way:

setInterval(function() {
    // refresh list
}, 5000)

where the second parameter is the number of milliseconds.

Note in everyTime

If you really want to use everyTime, you need to make your first parameter a string, i.e.:

$(document).everyTime("5s", function(i) { }, 0);

5s. javascript ( jQuery) , ..

<script type="text/javascript" src="/js/jquery.timers.js"></script> 
+14

5s , . :

$(document).everyTime(5000, function(i) {
  <?php include "recent.php";?>
}, 0);

, :

$(document).everyTime('5s', function(i) {
  <?php include "recent.php";?>
}, 0);

( )

+2

You can use everyTime plugin with jQuery Ajax as follows:

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 helps users explore similar features.

0
source

Source: https://habr.com/ru/post/1767987/


All Articles