School of Computing. Dublin City University.
Online coding site: Ancient Brain
coders JavaScript worlds
var obj = JSON.parse ( data );and then obj is a JS object containing all the data.
jsonFlickrFeed({ "title": "Recent Uploads tagged louvre", "link": "http://www.flickr.com/photos/tags/louvre/", "description": "", "modified": "2016-02-29T15:43:47Z", "generator": "http://www.flickr.com/", "items": [ { "title": "Louvre Sunset", "link": "http://www.flickr.com/photos/frankwiegand/25378218695/", "media": {"m":"http://farm2.staticflickr.com/1624/25378218695_99bf5c58ec_m.jpg"}, "date_taken": "2016-02-29T07:42:56-08:00", "description": " STRING OF HTML HERE ", "published": "2016-02-29T15:43:47Z", "author": "nobody@flickr.com (Frank Wiegand Photography)", "author_id": "132296773@N05", "tags": "autumn sunset paris france .... louvre herbst stadt wiegand" }, .... |
<script src="http://remote_site/script.js">
So script could include the data at the remote site.
and the site would return this:http://site/feed
the JSON data
and the site (which is designed to service JSONP calls) returns exactly this:http://site/feed?callback=fn
fn ( the JSON data )
then fn() gets run on the JSON data.<script src="http://site/feed?callback=fn">
and then the script gets run.var script = document.createElement("script"); script.src = url; document.head.appendChild(script);