How do I get the message and status values from this response
{"errors":[{"code":3,"message":"Invalid login details"}],"status":"failure"}
I've tried:
data.message
data['errors'].message
data[0].message
data.status
data[0].status
Edit:
I am parsing a res like this
var data = jQuery.parseJSON(jQuery(res).find('#container').text());
console.log(data.status);
console.log(data.errors[0].message);
The string I'm parsing is:
"{\"errors\":[{\"code\":3,\"message\":\"Invalid login details\"}],\"status\":\"failure\"}"
Answer:
The response I was getting was already being encoded as JSON, so once I made it a plain echo and kept the parsing on the client side via js and stripped the slashes from the res it now works as expected. Thank you all for commenting as it helped me a lot figure out what I was doing wrong