When a user clicks a button I want to return some data and iterate through the JSON so that I can append the results to a table row.
At this point I am just trying t
You need to add:
dataType: 'json',
.. so you should have:
$("#button").click(function(){
$.ajax({
url: 'http://localhost/test.php',
type: 'get',
dataType: 'json',
success: function(data) {
$.each(data.COLUMNS, function(item) {
console.log(item);
});
},
error: function(e) {
console.log(e.message);
}
});
});
.. as well as ensuring that you are referencing COLUMNS in the each statement.
getJson is also another way of doing it..
http://api.jquery.com/jQuery.getJSON/