Just starting learning about ajax requests using jQuery. I've tried looking at other posts on this but not sure how to implement it. Here's the code I have. Right now it's just getting the first 3 items. I want it to get 3 random items from the rss feed it's pulling. Here's what I have:
jQuery(document).ready(function($) {
$.ajax({
url: "http://thrive.local/wp-content/themes/thriveafrica/fetcher.php",
type: "GET",
success: function(d) {
$('item', d).slice(0, 3).each(function() {
var $item = $(this);
var title = $item.find('title').text();
var link = $item.find('link').text();
var description = $item.find('description').text();
var image = $(description).find('img').attr('src');
var price = $(description).find('span.SalePrice').text();
if (price == '') {price = 'Visit Store for Price'};
var html = '<li><a href="'+link+'" target="_blank">';
html += '<div class="image"><img src="'+image+'"></div>';
html += '<div class="info"><strong>'+title+'</strong><br/>'+price+'</div>';
html += '</a></li>';
// Example Output
// <li>
// <div class="image"><img src="http://www.thriveafricastore.com/product_images/s/041/coffee__59525_thumb.jpg"></div>
// <div class="info"><strong>Thrive Africa Blend (1lb)</strong><br>See Price</div>
// </li>
$('div#store ul').append($(html));
}); //End Each
} //End Success
}); // End Ajax Request
});
What are my options?
Thanks!