I’m using JQuery with CodeIgniter PHP to figure make AJAX calls and return data via JSON. I want to figure out what my JSON object has returned, but I’m not sure what the syntax might be. Is there a way to just alert or log all the contents of the JSON object somehow? This is my code:
$.ajax({
type: "GET",
url: groups_url,
success: function(parent){
alert (parent);
}
});
If I do this – I get an object, but I don’t know what it contains.
Learn to love the Javascript console. The
console.logmethod covers almost every eventuality — giving you a nicely formatted summary of the object (or array, string, number, or boolean) that you’re concerned with.You can see the log by a console built into your browser (e.g. Chrome console, the Firefox 4 web console, IE developer tools) or by using a plugin (e.g. Firebug for Firefox <4).