Reputation: 39
I have an ajaxpost that returns a response in form of json and I want to show the message
{ "TEXT" : "Please fix it. there might be otehr reason, and need to address it, or call, incorrect username/password-username/port?. " }
How can I get the value of json? I used the following but Message is undefined, What are the other ways of getting json object
var TEXT = text.resp;
Upvotes: 2
Views: 205
Reputation: 7562
Include this library and below code to parse your json
var json = $.parseJSON(obj.responseText);
var msg = json.message;
You can also try below code
var json = JSON.parse(obj.responseText);
var msg = json.message;
Upvotes: 1
Reputation: 4976
You should try to parse the object and then access it with json["object"] instead of the dot.
Upvotes: 0