0

I makinn an AJAX call that returns a JSON string. The JSON is either {"status":"success"} or {"status":"error"}.

I want to read the status JSON variable. I tried multiple ways but I wasn't able to get that. As of now I am able to log the string into console.

 success: function(data){
        console.log("embedded success");
        var jsondata = JSON.parse(data);
        console.log(jsondata);
 }
user3861559
  • 973
  • 8
  • 25
  • 43
  • possible duplicate of [Parse JSON in JavaScript?](http://stackoverflow.com/questions/4935632/parse-json-in-javascript) – Shawn Bush Feb 05 '15 at 18:01
  • Useful link: http://stackoverflow.com/questions/8951810/how-to-parse-json-data-with-jquery-javascript – jyrkim Feb 05 '15 at 18:05

1 Answers1

0

You can use either dot-notation or bracket-notation for Property Accessors. Either of the following will work:

console.log(jsondata.status);
console.log(jsondata["status"]);
Dave
  • 10,748
  • 3
  • 43
  • 54