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
-
Are you generating the JSON string? If so, how?Felix Kling– Felix Kling2011年02月22日 16:32:17 +00:00Commented Feb 22, 2011 at 16:32
2 Answers 2
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
Brad Christie
102k16 gold badges160 silver badges200 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
test this:
$.getJSON('yoururl', function(data) {
...
});
answered Feb 22, 2011 at 13:45
alexl
6,8083 gold badges26 silver badges29 bronze badges
Comments
lang-js