I\'ve written a webservice which returns JSON and I\'ve tried to call it using jQuery like this:
$.ajax({
contentType: \"application/json; charset=utf-8\
Thanks Nick, that was an excellent answer to a problem that I too had a hard time finding at first online. Worked great for me as well.
Wanted to make sure this this line of post got the attention it deserves.
Just wanted to add that I used the built in serializer (System.Runtime.Serialization.Json) and it worked like a charm as well.
List orderHistory = null;
StringBuilder sb = new StringBuilder();
JavaScriptSerializer js = new JavaScriptSerializer();
sb.Append(callback + "(");
sb.Append(js.Serialize(orderHistory));
sb.Append(");");
Context.Response.Clear();
Context.Response.ContentType = "application/json";
Context.Response.Write(sb.ToString());
Context.Response.End();