After getting an HTTP response in the form a JSON file, how can I handle its plain content using jQuery?
I've done this before, but I just can't figure out how right now.
I'm using this function to retrieve the JSON content.
var json = $.getJSON("test.json", function(response){ // do stuff } ); Of course, I can handle the data contained in the JSON, but I'd like to handle and print its plain content, like this:
{"name": "Pepe","age" : "20"} The following
alert(response); Just gives me [object Object]
And this
alert(jQuery.parseJSON(json)); Just gives me null
I can't seem to find the answer anywhere. I'm pretty new to all this, so I must be using the wrong search terms, because it looks like a trivial matter.
console.loginstead ofalertbecause it allows you to see what's inside the object.JSON.stringify(json)to convert it to plain text.