In-Page Element Updating/Refreshing
if ($('.autoupdate')[0]) { setInterval(function () { $.get(document.location, function (data) { $('.autoupdate').each(function () { var html = $(data).find('#' + $(this).id).html(); }); }); }, 10000); }
This is a great snippet from the Designer/Developer community at Forrst. 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.
I’ve spoken before about how costly the $.load() method is, but once more with feeling: it makes another call to the server for the entire page structure and then returns the elements from within that. This could be improved by using targeted AJAX calls that don’t get/return entire pages, but it still makes for a great prototype.
5 Notes/ Hide
-
rankandfile likes this
-
jotarun likes this
-
taitems posted this