Improve AJAX response handling function This code handles a response from an RSS feed. It organizes and appends to content. If there's a video embeded then separate it from the rest of the content. I would like a review mainly on performance/efficiency but I'm open to any other suggestions as well. That star selector is really nagging me but I don't know of a better way to iterate over all the contained elements.

function getFeed(url, element, callback) {
    $.getJSON("https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&amp;callback=?&amp;q="+encodeURIComponent(url), function(response) {
        var content = "",
            $element = $(element);

        for (var i = 0; i &lt; response.responseData.feed.entries.length; i++) {
            content = content + response.responseData.feed.entries[i].content; //Join all the feed entries
        }

        $element.find(".content").html(content).addClass($element.find("embed").length? "withVideo" : "");

        $element.find("*").each(function() {
            var $this = $(this);

            $this.removeAttr("style width align"); //Reset all the crap that comes with the response

            if ($this.is("embed")) {
                $element.append("&lt;div class='video'&gt;&lt;/div&gt;");
                $this.attr("width", 640).attr("height", 360).parent().appendTo(element + " .video");
            };
        });

        if (typeof callback === 'function') {
            callback();
        };
    });
}


This is then called like so:

getFeed("http://www.kent.k12.wa.us/site/RSS.aspx?PageID=3854", "#TechExpo", optionalCallback);


Here's what a response might look like

&lt;div width="500" style="whatever"&gt;&lt;p&gt;Some text blah blah blah.&lt;/p&gt;
&lt;p align="right"&gt;Some more text&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;&lt;h2&gt;Video Title&lt;/h2&gt;
&lt;embed src="http://..." width="360" height="202" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;
&lt;small&gt;Watch the 7th annual Tech Expo highlights.&lt;/small&gt;&lt;/div&gt;
Late reply,

this code is good, I can only find 2 faults:


Your code should have error handling for the JSON call, things can go wrong
Too much horizontal stretching, I would introduce some sugar for this:

for (var i = 0; i &lt; response.responseData.feed.entries.length; i++) {
    content = content + response.responseData.feed.entries[i].content; //Join all the feed entries
}


could be

var entries = response.responseData.feed.entries;
for (var i = 0; i &lt; entries.length; i++) {
    content = content + entries[i].content; //Join all the feed entries
}


Also, I find

$element.find(".content").html(content)
                         .addClass($element.find("embed").length? "withVideo" : "");


more readable.


As for find("*"), it seems to be cleanest way to access all children.