var s = "";
$(function () {
$("#open").click(function () {
$.ajax({
type: "post",
url: "../Master/Ma.ashx",
data: { 'UserID': "admin" },
dataType: "json",
error: function () {
window.location.href = "/Web/Error.aspx";
},
success: function (json) {
alert(json);
}
})
})
});
这个是前台js
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string str = "";
DataSet ds = new DataSet();
string UserID = context.Request["UserID"].ToString();
ds = DBhelper.ProcQueryData("Sp_GetNavigation", new IDataParameter[] { new SqlParameter("@UserID", UserID) });
if (ds.Tables[0].Rows.Count > 0)
{
//将对象序列化为stringjson
str = DataSetToJson(ds).ToString();
}
context.Response.Write(str);
}
上面的是后台 。ashx
str
json的内容弹不出来!!!怎么回事啊?如果要访问json中的数据该如何写循环遍历?
苍天···