Created
August 18, 2013 11:36
-
-
Save skippednote/6261226 to your computer and use it in GitHub Desktop.
Ajax request to sub-reddit
This file contains 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
$.ajax({ | |
url: 'http://www.reddit.com/r/aww/.json?jsonp', | |
dataType: 'jsonp', | |
success: function( resp ) { resp.data.children.forEach(function(entry, i){ | |
var pic = "<img src="+ entry.data.url+">"; | |
console.log(i); | |
$("#target").append("<li>" + pic + "</li>"); | |
i++; | |
}); | |
}, | |
error: function( req, status, err ) { | |
console.log( 'something went wrong', status, err ); | |
}, | |
jsonp : 'jsonp' | |
}); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> | |
<script src="app.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="target"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment