jquery ajax ashx返回值为空求解
各位大神帮我看个问题,
<body onload="funStateJudge();">
function funStateJudge() {
$.ajax({
url: "Service/PassWordJudge.asmx/StateJudge",
contentType: "application/json",
dataType: "json",
data: "{}",
type: "POST",
success: function (json) {
//alert(json.d);//输出结果
if (json.d == "1") {
document.getElementById("divState").style.visibility = "visible";
funGetUserData(); //显示获取登陆信息
}
else {
funShowpnlLogin();
document.getElementById("divState").style.visibility = "hidden";
}
},
error: function (x, e) {
alert(x.responseText);
errorSolve(); //异常处理
}
});
}
function funGetUserData() {
$.ajax({
url: "Service/GetSessionValue.ashx",
contentType: "application/json",
dataType: "json",
type: "POST",
data: "{}",
success: function (json) {
// alert(json.UserName); //输出结果
// alert(json.UserAccount); //输出结果
document.getElementById("lbtnUserName").innerText = json.UserName; //显示输出用户姓名
document.getElementById("lbtnUserAccount").innerText = json.UserAccount; //显示输出用户帐号
},
error: function (x, e) {
funGetUserData(); //重复调用,方式页面加载时调用失败{这里两个页面之间来回跳转时无规律的出现失败现象,返回结果为空,反复调用即可得到返回值。。求解}
}
});
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string strData = String.Format("{{UserName:"{0}",UserAccount:"{1}"}}", getUserName(), getUserAccount());//构建的json数据
//下面两句是用来测试前台向此页面发出的查询字符
context.Response.Write(strData);
}