I'm using jquery to send a json string to an ASMX web service. The code behind for the web service method definition looks like this:
[WebMethod(EnableSession = true)]
public string DoMyProcess(string TheDataID, string TheUserID, string TheData) {
The string TheData is a javascript object MyObject that I serialize using
var TheData = JSON.stringify(MyObject);
The jquery part that sends the json looks like this:
var AjaxData = '{"TheDatatID":"' + DatatID + '","TheUserID":"' + UserID + '","TheData":"' + TheData + '"}';
$.ajax({
type: "POST",
url: "../WebServices/MyServices.asmx/DoMyProcess",
data: AjaxData,
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: "false",
success: RequestSuccess,
error: RequestError
});
As it is, I get a 500 error and the debugger doesn't even fire in VS. However, if I replace var TheData = JSON.stringify(MyObject); with
var TheData = "test";
I'm able to get the debugger to break on the first line of the code behind file.
This must be the result of a problem when sending json within json; it should work but it doesn't. What am I missing?