I have the following webmethod on my asp.net code behind page:
[WebMethod(EnableSession = true)]
public static bool SaveFailureData(SimpleFailureData data)
{
ok try this
public static bool SaveFailureData(string sampleFailure)
{
JavaScriptSerializer s = new JavaScriptSerializer();
SimpleFailureData sdata = s.Deserialize(sampleFailure);
return true;
}
var json = {
"Comments": "",
"Score": 66.66666666666667,
"Adjustment": 0,
"ShutdownData": [{ "Id": "401", "CausedShutdown": true, "ShutdownType": "NORMAL"}]
}
var data = JSON.stringify(json);
$.ajax({
type: "POST",
url: 'Default.aspx/SaveFailureData',
contentType: 'application/json; charset=utf-8',
data: "{'sampleFailure' : '" + data + "'}",
// data: data,
dataType: 'json',
success: function (msg) {
alert(msg.d);
},
error: function (msg) {
alert('Error!');
}
});
});
you will get the data in sdata object.