I get the below response from an ajax call, but when I try to console.log the values it returns undefined
when i console.log(data) is returns the following code.
{ "status": false, "message": "video call must be 11 digits long" }
but the other console.log values returns undefined...see below...I want to pick the status and the content of the message and log it to console.
ajax.done(function (data) {
console.log(data);
console.log(data.status);
console.log(data['message']);
}
LOG
{ "status": false, "message": "video call must be 11 digits long" }
this is my content type 'Content-Type: application/json',
Try to add
dataType: "json"
to your request's params or
let response = JSON.parse(data);
console.log(response.status);
let response = JSON.parse(data); console.log(response.status);
This works..thanks to everyone for your help