var handler = "HttpHandlers/UpdateAdditionalCoverageDetailsHandler.ashx";
var coverages = { PersonID: personId, DetCode: "", Reimbursement: "", Deductible: "", MaximumPerAnnum: "", MaximumPerVisit: "", MaximumPerVisits: "", SvcCode: "" };
var maximums = { PersonID: personId, DetCode: ["ACUPUN", "PODIAT", "OSTEOP"], MaximumPerAnnum: "" };
var obj = { Coverages: coverages, CoverageCombinedMaximums: maximums };
var objJson = JSON.stringify(obj);
var data = '{ "items":' + objJson + '}';
callHandler(handler, data, saveSuccessful, failure);
和我调用处理程序的函数:
function callHandler(handler, obj, onSuccess, onFail) {
$.ajax({
type: "POST",
url: handler,
data: obj, // obj,
//contentType: "application/json; charset=utf-8",
dataType: "json",
success: onSuccess,
fail: onFail
});
}
和我的处理程序中的方法:
public void ProcessRequest (HttpContext context) {
bool isSuccessful = true;
var items = context.Request.Params["items"];
if (isSuccessful)
{
JavaScriptSerializer ser = new JavaScriptSerializer();
Dictionary<string,object> dict = ser.Deserialize<Dictionary<string, object>>(items);
}
else
{
SendErrorMessage(context);
return;
}
}