前台:
復制代碼 代碼如下:
$.ajax({
type: "POST",
url: "GetMenuRole.ashx",
data: "",
dataType: "json",
success: function (data) {
if (data.Status == false) {
alert(data.ErrorReason);
}
else {
//解析這個菜單列表
alert(data.MenuList);
}
},
error: function (data) {
alert(data);
}
});
後台:(需要使用雙引號) 復制代碼 代碼如下:
string sReturnJson = " <KH>\"Status\":\"{0}\",\"MenuList\":\"{1}\",\"ErrorReason\":\"{2}\"</KH>";
sReturnJson = string.Format(sReturnJson, "True", sReturnMenuList,string.Empty).Replace("<KH>","{").Replace("</KH>","}");
context.Response.Write(sReturnJson);