Forked from chrisjason/espn-research-notes-api-sample_javascript.js
Last active
August 29, 2015 14:14
-
-
Save noomerikal/4bb9107596072ec6ce6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example JSONP request with jQuery | |
$.ajax({ | |
url: "http://api.espn.com/v1/sports/news/notes", | |
data: { | |
// enter your developer api key here | |
apikey: "{api key}", | |
// the type of data you're expecting back from the api | |
_accept: "application/json" | |
}, | |
dataType: "jsonp", | |
success: function(data) { | |
// create an unordered list of research notes | |
var ul = $('<ul/>'); | |
$.each(data.notes, function() { | |
var li = $('<li/>').text(this.headline); | |
ul.append(li) | |
}); | |
// append this list to the document body | |
$('body').append(ul); | |
}, | |
error: function() { | |
// handle the error | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment