i’m developing an web application in .net platform.
i have wrote an Handler code that return a JSON object to Javascript (after i request in AJAX).
the Handler code:
var wrapper = new {
left = left.ToString(),
top = top.ToString(),
width = width.ToString(),
height = height.ToString() };
context.Response.Write(JsonConvert.SerializeObject(wrapper));
In Javascript, when i do alert, i see that i get an object. and it’s good.
But now i want to parse it to JSON.
when i do JSON.parse(msg); i get an error
“JSON.parse: unexpected character”
when i do jQuery.parseJSON(msg); using jquery-1.6.2, i get this error
jQuery.parseJSON is not a function (i’m using jquery-1.6.2)
What is the problem?
Try this.
Create a page called TestPage.aspx like this.
And on TestPage.aspx.cs, do this
Hope this helps.
Courtesy: ASP.NET web services mistake: manual JSON serialization by Dave Ward