admin管理员组

文章数量:1406914

Problem:

Values constantly change on db. Need to auto-reload certain elements values without reloading all page. Very similar to collective bidding pages as attached image.

A simple page Dashboard type with three columns of grid organized data.

How can I effectively reload (AJAX CALL) certain class types, content?

Since these column values change as time goes from db, they have to auto refresh on time interval.

Code Sample:

<div class="autovalue">26</div>
<div class="autovalue">20</div>
<div class="autovalue">96</div>

Maybe Jquery has a method.

Problem:

Values constantly change on db. Need to auto-reload certain elements values without reloading all page. Very similar to collective bidding pages as attached image.

A simple page Dashboard type with three columns of grid organized data.

How can I effectively reload (AJAX CALL) certain class types, content?

Since these column values change as time goes from db, they have to auto refresh on time interval.

Code Sample:

<div class="autovalue">26</div>
<div class="autovalue">20</div>
<div class="autovalue">96</div>

Maybe Jquery has a method.

Share Improve this question asked Mar 1, 2011 at 18:03 Codex73Codex73 5,77613 gold badges58 silver badges77 bronze badges 1
  • You could use jquery's $.ajax methods, then on successful postback change the style of the surrounded div/span to reflect the change. – dmackerman Commented Mar 1, 2011 at 18:04
Add a ment  | 

1 Answer 1

Reset to default 3

Set an interval function, i did this example using jQuery.

var intervalID = setInterval(function(){
   $('.refreshClass').each(function(){
      $(this).load(this.href);
   })
}, 900);

In my example <a href="url-to-get.php" class="refresh"></a> will request the href attribute every 900ms and update the innerHtml.

For a better performance you can cache your selectors and use id instead of classes. :)

本文标签: ajaxJavascript AutoRefresh Class ElementsStack Overflow