user2781855
user2781855

Reputation: 39

try to get the value of json object

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

Answers (2)

Jitendra Pancholi
Jitendra Pancholi

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

Justin D.
Justin D.

Reputation: 4976

You should try to parse the object and then access it with json["object"] instead of the dot.

Upvotes: 0

Related Questions