Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  25] [ 1]  / answers: 1 / hits: 111911  / 13 Years ago, mon, april 11, 2011, 12:00:00
{id:2231f87c-a62c-4c2c-8f5d-b76d11942301}


If I alert the response data I see the above, how do I access the id value?



My controller returns like this:



return Json(
new {
id = indicationBase.ID
}
);


In my ajax success I have this:



success: function(data) {
var id = data.id.toString();
}


It says data.id is undefined.


More From » json

 Answers
18

If response is in json and not a string then



alert(response.id);
or
alert(response['id']);


otherwise



var response = JSON.parse('{id:2231f87c-a62c-4c2c-8f5d-b76d11942301}');
response.id ; //# => 2231f87c-a62c-4c2c-8f5d-b76d11942301

[#92803] Saturday, April 9, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
micayla

Total Points: 148
Total Questions: 92
Total Answers: 109

Location: Aruba
Member since Sat, Oct 2, 2021
3 Years ago
micayla questions
Fri, Dec 24, 21, 00:00, 2 Years ago
Thu, Apr 16, 20, 00:00, 4 Years ago
Thu, Nov 14, 19, 00:00, 5 Years ago
;