Xml:
<Data>
<Cat>
<Name>Fluffy</Name>
</Cat>
<Cat>
<Name>Willy</Name>
</Cat>
</Data>
JQuery:
// ...Some ajax calls...
$(xml).find('Cat').each(function() {
var name = $(this).find('Name').text();
alert(name);
});
How can I store the results of find('Cat') in a variable, so that I can pass it to a function and handle it there? I thought something like this, but it doesn't work:
var cats = $(xml).find('Cat');
ShowCatNames(cats);
...
function ShowCatNames(cats) {
$(cats).each(function() {
var name = $(this).find('Name').text();
alert(name);
}
}
Thank you.