Milos Cuculovic
Milos Cuculovic

Reputation: 20223

Parse JSON response got from AJAX request through JavaScript

I'm geting a JSON response with an AJAX request through JavaScript.

Here is the response:

{"responseCode":400,"errors":false,"submitted":false,"content":"some content","notice":""}

My Goal is to get the content:

"some content"

The json variable is the data in my case. So, I have tried with:

data.content

But I am geting an empty string.

Any idea on how to access the string?

Thank you in advance.

Upvotes: 17

Views: 74698

Answers (1)

Dejo
Dejo

Reputation: 2148

Did you first parse json ?

var data = JSON.parse(json);

than read data.content

Upvotes: 47

Related Questions