json各种我们都知道 {"key1":"value1","key2":"value2"} 前端js代码如下:
$.post("InternalBillHandle.ashx", function (data, textStatus, jqXHR) {
$("#totalInternal").text(data.totalInternal);
$("#successInternal").text(data.successInternal);
$("#failInternal").text(data.failInternal);
$("#successExpense").text(data.successExpense);
$("#failExpense").text(data.failExpense);
}, "json");
后台拼接的json如下:
var ret = "{'totalInternal':" + totalDataTable.Rows.Count + ",'successInternal':" + internalBillsSuccessfullyDataTable.Rows.Count + ",'failInternal':" + internalBillsFailureDataTable.Rows.Count + ",'successExpense':" + expenseItemSuccessfulDataTable.Rows.Count + ",'failExpense':" + expenseItemFailureDataTable.Rows.Count + "}";
问题来了,现在始终触发不了jq的回调函数, 这是为什么呢, 原因是他的引号, 我将代码改成下面就能触发:
var ret = "{\"totalInternal\":" + totalDataTable.Rows.Count + ",\"successInternal\":" + internalBillsSuccessfullyDataTable.Rows.Count + "}";