Skip to content

Instantly share code, notes, and snippets.

@collegeman
Created October 14, 2010 14:37
Show Gist options
  • Save collegeman/626262 to your computer and use it in GitHub Desktop.
Save collegeman/626262 to your computer and use it in GitHub Desktop.
<!-- 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