17

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.

1
  • Have you parsed the json response? If not try JSON.parse(data) Commented Jan 23, 2013 at 11:07

1 Answer 1

47

Did you first parse json ?

var data = JSON.parse(json);

than read data.content

Sign up to request clarification or add additional context in comments.

2 Comments

Yup, or use something like jQuery.parseJSON for older browsers.
@Dejo Dude its Work Like a charm :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.