A simple jsonp library written in oop javascript
- Does nothing but log returned data in console.
$jsonp('http://en.wikipedia.org/w/api.php?grnnamespace=0&format=json&callback=?&action=query&generator=random&callback=callback');
- Options can be passed in as plain object
$jsonp('http://en.wikipedia.org/w/api.php?grnnamespace=0&format=json&callback=?&action=query&generator=random&callback=callback', {
onSuccess: function(json) {
console.log('success!', json);
var pageObj = json.query.pages;
var pageId = Object.keys(pageObj)[0];
box.innerHTML = pageObj[pageId].title;
},
onTimeout: function() {
console.log('timeout!');
},
timeout: 5
});