1) Form a request using multiple locations (i am using attrIds for it) or single location and make ajax calls to trip advisor
2) Get data via callback method (setAttractionsRating in my case) and bind it to the respective fields on screen. I have looped through all controls on screen with class ratings where i need to display tripadvisor data.
//set attraction rating from trip advisor fetched data
$(".rating").each(function () {
var ratingDiv = $(this);
var locId = ratingDiv.attr("data-attrid");
var matchFound = false;
for (i = 0; i < response.data.length; i++) {
if (locId == response.data[i].location_id) {
ratingDiv.attr("data-original", response.data[i].rating_image_url);
ratingDiv.next('a').attr("href", response.data[i].web_url);
ratingDiv.next('a').text(response.data[i].num_reviews + " reviews");
ratingDiv.next('a').next('a').attr("href", response.data[i].write_review);
ratingDiv.next('a').next('a').text("Write a Review");
attractionIds.push(response.data[i].location_id);
attrRatingImgUrl.push(response.data[i].rating_image_url);
attrReviewCount.push(response.data[i].num_reviews);
attrReviewUrl.push(response.data[i].web_url);
attrWriteReviewUrl.push(response.data[i].write_review);
break;
}
}
});