Skip to content

Instantly share code, notes, and snippets.

@achudars
Last active December 17, 2015 00:19
Show Gist options
  • Save achudars/5520461 to your computer and use it in GitHub Desktop.
Save achudars/5520461 to your computer and use it in GitHub Desktop.
jQuery Ajax & Get JSON Array
$.ajax({
type: 'POST',
url: 'url.php',
data: 'nombre=' + $('#nombre').val() + '&' + 'edad=' + $('#edad').val(),
dataType: 'json',
success: function(data){
var html = '';
$.each(data,function(index,user){
html+= '<div class="user"><p>' + index + '</p>';
html+= '<p>' + user.user_edad + '</p></div>';
});
$('#users').html(html);
},
error: function(data){
alert('Error:' + data);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment