Created
October 14, 2010 14:37
-
-
Save collegeman/626262 to your computer and use it in GitHub Desktop.
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
<!-- how to pull JSON from another domain and use it to generate HTML --> | |
<div id="container"></div> | |
<script> | |
$.ajax({ | |
// path to the JSON file | |
url: 'http://yourdomain.com/data.json', | |
// use JSONP to get around cross-domain restrictions, see: http://api.jquery.com/jQuery.ajax/ | |
dataType: 'jsonp', | |
// upon download | |
success: function(data) { | |
$.each(data.item, function(i, item) { | |
// generate HTML | |
$('#container').append('<li>'+item+'</li>'); | |
}); | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment