jquery “everyTime” function

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

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 so far, I don't really know how to get it to work... It's not working:\

  

This is default. Waiting for refresh

回答1:

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.



回答2:

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) {    }, 0); 

or a string indicating the interval:

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

(here's a reference)



回答3:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!