Skip to content

Instantly share code, notes, and snippets.

@CyberStrike
Last active August 29, 2015 13:57
Show Gist options
  • Save CyberStrike/9915275 to your computer and use it in GitHub Desktop.
Save CyberStrike/9915275 to your computer and use it in GitHub Desktop.
Using a jQuery's $.each
$.ajax({
url: 'http://api.randomuser.me/?results=10',
dataType: 'json',
success: function(data) {
addUsername(data);
}
});
addUsername = function(data) {
$.each(data.results, function(i) {
$('body').append('<p>' + data.results[i].user.name.first + ' ' + data.results[i].user.name.last + '</p>');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment