Based on this tutorial: JSON Web Service And jQuery with Visual Studio 2008
The Web Method returns a Product that is serialized in JSON format. Since there is not JSON
type, the returned value is a String
with JSON format.
On the client side, the ajax call returns a JSON.
The result looks like {d: 'returned-string-with-JSON-format'}
More exactly something like: {d:'{"ID":123,"Name":"Surface Pro 2"}'}
Note that 'returned-string-with-JSON-format'
is a string not a JSON object so you cannot do result.d.ID
.
Instead you need to convert it to JSON object by using JSON.parse(result.d)
or eval(result.d)
At the end, what you really want is do this:
result = JSON.parse(result.d)
UPDATE
Also consider this demo, where I use a JSON in string format and convert it to JSON object: