Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery JSON Parse - Unexpected Token Error
    text
    copied!<p>I'm trying to use Envato API to gather some user stats w/ jQuery. I'll show an example response JSON:</p> <pre><code>{ "new-files-from-user":[ { "thumbnail":"http://3.s3.envato.com/files/60560.jpg", "tags":"", "user":"collis", "url":"http://themeforest.net/item/manilla-photoshop-design/22803", "live_preview_url":"http://2.s3.envato.com/files/60561/1_Home.__large_preview.jpg", "uploaded_on":"Wed Dec 03 03:32:35 +1100 2008", "cost":"10.00", "item":"Manilla Photoshop Design", "sales":"294", "rating":"4", "id":"22803" }, { "thumbnail":"http://2.s3.envato.com/files/60223.jpg", "tags":"clean", "user":"collis", "url":"http://themeforest.net/item/black-white-simple-theme/22705", "live_preview_url":"http://0.s3.envato.com/files/60224/1_home.__large_preview.jpg", "uploaded_on":"Tue Dec 02 04:01:12 +1100 2008", "cost":"8.00","item":"Black + White Simple Theme", "sales":"272"," rating":"4", "id":"22705" }, { "thumbnail":"http://1.s3.envato.com/files/44556.jpg", "tags":"clean", "user":"collis", "url":"http://themeforest.net/item/quik-v1-admin-skin/17314", "live_preview_url":"http://3.s3.envato.com/files/44557/1_green.__large_preview.jpg", "uploaded_on":"Fri Sep 05 07:30:24 +1000 2008","cost":"12.00", "item":"Quik v1 Admin Skin", "sales":"336", "rating":"5", "id":"17314" }, {"thumbnail":"http://3.s3.envato.com/files/45212.jpg", "tags":"clean", "user":"collis", "url":"http://themeforest.net/item/freshcorp-business-template/17528", "live_preview_url":"http://3.s3.envato.com/files/45213/1_Homepage.__large_preview.jpg", "uploaded_on":"Tue Sep 09 06:10:50 +1000 2008", "cost":"20.00", "item":"FreshCorp - Business Template", "sales":"277", "rating":"4","id":"17528" }, {"thumbnail":"http://0.s3.envato.com/files/45739.jpg", "tags":"clean", "user":"collis", "url":"http://themeforest.net/item/real-estate-html-template/17732", "live_preview_url":"http://0.s3.envato.com/files/45740/1_homepage.__large_preview.jpg", "uploaded_on":"Fri Sep 12 14:22:45 +1000 2008", "cost":"20.00","item":"Real Estate HTML Template", "sales":"175", "rating":"4", "id":"17732" } ] } </code></pre> <p>Here's my script:</p> <pre><code>&lt;script type="text/javascript"&gt; //this gets JSON data from an url $.getJSON("http://marketplace.envato.com/api/edge/new-files-from-user:collins,themeforest.json?callback=?", //this function gets called when data has been recieved function(data){ //parsing JSON data, line by line(like foreach) $.each(data['new-items-from-user'], function(i,item){ //puts all titles in our div $("#test").append(item.item+"&lt;br /&gt;"); }); }); &lt;/script&gt; &lt;div id="test"&gt;&lt;/div&gt; </code></pre> <p>And here's what I get in the Chrome console: 'Uncaught SyntaxError: Unexpected Token :' (pic <a href="http://imgur.com/8qoqO" rel="nofollow">http://imgur.com/8qoqO</a>).</p> <p>I'm not sure if I have an error in my code that's causing this problem, but here's a fiddle to see the result: <a href="http://jsfiddle.net/wkmDj/" rel="nofollow">http://jsfiddle.net/wkmDj/</a></p> <p>Thanks, Matt</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload