I am working on a school project that involves extracting product data from multiple online retailers using various APIs/AJAX calls, and then sorting this data in PHP (I use one AJAX call for each retailer). A snippet of the code I am working on is shown below. I cannot figure out how to
Push a temporary array containing product attributes ("Average", "Price", "Name", "Url", and "Image") for each product into a master array (array of arrays) and then
Post this master array to PHP in such a way that I can index the values in it for sorting purposes.
function get_results() {
$(document).ready(function() {
var master_array = [];
$.ajax({
type: "GET",
url: "http//:www.source1.com",
dataType: "xml",
success: function(xml) {
$(xml).find('product').each(function() {
var Average = $(this).find('Average').text();
var Price = $(this).find('Price').text();
var Name = $(this).find('Name').text();
var Url = $(this).find('Url').text();
var Image = $(this).find('Image').text();
master_array.push([Average, Price, Name, Url, Image]);
});
}
});
$.ajax({
type: "GET",
url: "http//:www.source2.com",
dataType: "xml",
success: function(xml) {
$(xml).find('product').each(function() {
var Average = $(this).find('Average').text();
var Price = $(this).find('Price').text();
var Name = $(this).find('Name').text();
var Url = $(this).find('Url').text();
var Image = $(this).find('Image').text();
master_array.push([Average, Price, Name, Url, Image]);
});
}
});
});
}