php - Jquery parsing response from api bbyopen -
I have trouble parsing this API, can you see what I have done?
PHP kernel call:
// Creating a new curl resource $ ch = curl_init (); // set URL and other appropriate options $ options = array (CURLOPT_URL = & gt; 'http://api.remix.bestbuy.com/v1/products(salePrice<='.$dollars.'&type=Music) ? ApiKey = gzunxsecretsdssf444and format = json & show = name, salePrice, shortDescription, image ', CURLOPT_HEADER = & gt; wrong, CURLOPT_RETURNTRANSFER => 1); Curl_setopt_array ($ ch, $ option); // grab the URL and pass it to the browser echo curl_xac ($ f); // Close curl processing, and curl_close ($ ch) for free system resources; JS:
$ Ajax ({url: "./file.php", type: 'GET', datatype: 'JSON', success: work (data) {console.log ("success"); for console.log (data); (Var i = 0; i & lt; = data.products.length; i ++) {var thumb = data.products [I] .image; $ ('& lt; div class = "product" style = "background Color: green "> gt; & lt; / div & gt;) .appendTo ('# find_stuff_div');}}}); var thumb = data.products [i] .image; Where the object logs itself (apparently JSN) but the work thumb returns "Unkot type error: can not read the 'image' property of the undefined. Any thoughts?
Console log < Img src = "https://i.stack.imgur.com/pp8R6.jpg" alt = "console">
You must call returned data to use JSON.parse () as an item.
Comments
Post a Comment