I’m using the code below to load an XML file of movie reviews with release years of 2008, 2009, and 2010:
function showReviews(relYear) {
$(document).ready(function() {
$.get("reviews.xml", function(response,status,xhr){
var rootObj = response.documentElement;
revArray = rootObj.getElementsByTagName('review');
relyearArray = rootObj.getElementsByTagName('releaseyear');
revIdArray = rootObj.getElementsByTagName('review_id');
ftitleArray = rootObj.getElementsByTagName('filmtitle');
//loops through arrays to display movie reviews
loadReviews(relYear);
});
});
}
This loads the entire XML file. Once it’s loaded I loop through
the arrays to display the reviews for the selected release year. It works but
it seems pretty inefficient.
I read some jquery docs and posts about $.get and it appears that $.get or
#.ajax will accept a param that will limit the response data to only the
release year selected, but I don’t understand how to apply the param.
Can anyone help with this?