jquery ajax load method: only one request for multiple elements? -
hey, have 10 "ul.rating" elements on page. want refresh elements every minute.
var reload = 60000; var currentpage = window.location; setinterval(function() { $('ul.ratings').load(currentpage + " .ul.ratings >*", function() { //callback }); }, reload);
now have following 2 problems.
i need find away reload each element new. right i'm reloading same ul.ratings element ul.ratings elements on page. there must way use index() or other jquery method reload first ul.ratings element first ul.ratings element , reload fifth ul.ratings element fifth ul.ratings elment.
the whole thing rather bad way this, guess in case there no better way. possible load-method once , grab each ul.ratings element , replace correct one? right i'm doing load-calls if there 10 ul.ratings elements on page.
thank help!
do have control on url call? can make return data want? in case, let return json or xml , reload ul's information.
otherwise, use $.get function, load html in jquery , find ul's yourself:
var ulorigs = $('ul.ratings'); $.get('url', function (data) { var content = $(data); $('ul.ratings', content).each(function(ind,elem) { $(ulorigs.get(0)).html($(elem).html()); }); });
i did not run code myself.
Comments
Post a Comment