In-Page Element Updating/Refreshing


/ Published in: jQuery
Save to your folder(s)

Essentially it refreshes the content of any element in the page that has the “autoupdate” class on it. It uses the jQuery AJAX load method to get the page and replaces all the content within the new content from their matching IDs.


Copy this code and paste it in your HTML
  1. if ($('.autoupdate')[0]) {
  2. setInterval(function () {
  3. $.get(document.location, function (data) {
  4. $('.autoupdate').each(function () {
  5. var html = $(data).find('#' + $(this).id).html();
  6. });
  7. });
  8. }, 10000);
  9. }​

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.