这个是JS文件
$.getJSON("regcheckuserjson.ashx", function (date) {
if (date.success == 1) {
alert('成功');
} else {
alert('失败');
}regcheckuserjson.ashx 文件 public void ProcessRequest (HttpContext context) { string notice = "[{'success':'1'}]";
context.Response.ContentType = "text/plain";
context.Response.Write(notice);
}为什么我获取这个文件得到的是 alert('失败');获取“1”这个值应该是成功啊
$.getJSON("regcheckuserjson.ashx", function (date) {
if (date.success == 1) {
alert('成功');
} else {
alert('失败');
}regcheckuserjson.ashx 文件 public void ProcessRequest (HttpContext context) { string notice = "[{'success':'1'}]";
context.Response.ContentType = "text/plain";
context.Response.Write(notice);
}为什么我获取这个文件得到的是 alert('失败');获取“1”这个值应该是成功啊
改:
string notice = "{'success':'1'}";
都是以{开头。。
这个应该可以的把,或者
if (date[0].success == 1) {
alert('成功');
} else {
alert('失败');
}