I am having trouble parsing from this api. Can you see what I have done?
The PHP Curl Call:
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
$options = array(CURLOPT_URL => 'http://api.remix.bestbuy.com/v1/products(salePrice<='.$dollars.'&type=Music)?apiKey=gzunxsecretsdssf444&format=json&show=name,salePrice,shortDescription,image',
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => 1
);
curl_setopt_array($ch, $options);
// grab URL and pass it to the browser
echo curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
The js:
$.ajax({
url: "./file.php",
type: 'GET',
dataType: 'JSON',
success: function (data) {
console.log("Success");
console.log(data);
for(var i=0;i<=data.products.length;i++)
{
var thumb=data.products[i].image;
$('<div class="product" style="background-color:green"><a href=""><img src="'+ thumb +'" alt""/></a></div>').appendTo('#find_stuff_div');
}
}
});
var thumb=data.products[i].image; is where I am having trouble. The object itself logs (apparently as json) but var thumb returns "Uncaught TypeError: Cannot read property 'image' of undefined ". Any ideas?
Console log