Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery each on a JSON api
    text
    copied!<p>I'm trying to loop through the NY Times' search API. The resulting JSON looks like this:</p> <pre><code>{"offset" : "0" , "results" : [{"body" : "NEW ORLEANS &amp;mdash; The hemorrhaging well that has spilled millions of gallons of oil into the Gulf of Mexico remained capped for a second day Friday, providing some hope of a long-term solution to the environmental disaster. Live video from the seabed Friday morning showed that all was quiet around the top of the well, suggesting the test" , "byline" : "By CAMPBELL ROBERTSON and HENRY FOUNTAIN" , "date" : "20100717" , "title" : "Oil Spill Capped for a Second Day, Offering Some Hope" , "url" : "http:\/\/www.nytimes.com\/2010\/07\/17\/us\/17spill.html"} , {"body" : "GALVESTON, Tex. &amp;mdash; The crayons and paper were out, but not too many children made it to family day at the Ocean Star Offshore Drilling Rig and Museum . Granted, the exhibits of pipelines and seismic vessels may have been over the heads of many grade-schoolers. And despite a few cheerful displays about marine life around rigs and all the bounty" , "byline" : "By MELENA RYZIK" , "date" : "20100716" , "title" : "Texas Remains Stoic as Spill Hits Its Shores" , "url" : "http:\/\/www.nytimes.com\/2010\/07\/16\/us\/16galveston.html"} </code></pre> <p>(that's just two in the larger 'results' set)</p> <p>Here's the code I'm using (with my API key removed)</p> <pre><code>$.getJSON('http://api.nytimes.com/svc/search/v1/article?format=json&amp;query=oil%2C+bp%2C+gulf+of+mexico&amp;api-key=KEY_REMOVED'+'&amp;callback=?', function(e) { $.each(e.results, function() { $('#slippery').appendTo( '&lt;h2&gt;' + this.title + '&lt;/h2&gt;' ); }); }); </code></pre> <p>I feel like this should work to loop through and print all the story titles, but it's not. The Chrome dev tools return two errors: "Uncaught SyntaxError: Unexpected token" and "Resource interpreted as script but transferred with MIME type text/plain"</p> <p>I'm still working my way through Jquery parsing of JSON, so I'm sure I'm doing something simple incorrectly. Any help would be much appreciated.</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