0

I am getting this response in $.ajax success method.

{\"ID\":18,"TSName":"testSuit"}

How can I parse it like

success: function (response) {
 var tr = response.d;
 alert(tr.TSName);
Brad Christie
102k16 gold badges160 silver badges200 bronze badges
asked Feb 22, 2011 at 13:40
1
  • Are you generating the JSON string? If so, how? Commented Feb 22, 2011 at 16:32

2 Answers 2

1

Check out the dataType option of jQuery's .ajax call. If you specify JSON, jQuery will parse it for you in to the object you're looking for.

Alternatively, you can pass the data to .parseJSON and you will get a JSON object back.

answered Feb 22, 2011 at 13:45
Sign up to request clarification or add additional context in comments.

Comments

1

test this:

$.getJSON('yoururl', function(data) {
 ...
});
answered Feb 22, 2011 at 13:45

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.