I'm having some trouble figuring out why this isn't working: $(links).each(function(i){ $.get(i, function(data){ var trimmedToList = $(data.slice(data.indexOf('\<div id="media">'),data.indexOf('\<div class="description">'))).html(); $('#media').append(trimmedToList); }); });
It's supposed to retrieve the page of each link in the "links" array, then parse it using slice() to return only the bit of the page I want, then append the new content to the '#media' div. I checked it in firebug and the variable "trimmedToList" is showing as undefined. The strange thing is, if I type the code in manually into firebug one function at a time, it works. I thought this could be a timing issue, so I tried putting in the "opacity pause" trick: $(links).each(function(i){ $.get(i, function(data){ $('body').animate({opacity: 1.0}, 9000) var trimmedToList = $(data.slice(data.indexOf('\<div id="media">'),data.indexOf('\<div class="description">'))).html(); $('#media').append(trimmedToList); }); }); but it still didn't seem to work. I just can't figure out why "$ (data.slice(data.indexOf('\<div id="media">'),data.indexOf('\<div class="description">'))).html();" isn't being assigned to the "trimmedToList" variable. :(