asp.net后台与ajax交互数据的问题 Response.ContentType = "application/json"; 这个表示你的响应内容是 json 格式。报错说明你认为name:'newName' 是json格式的想法是错的。你自己再试试。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我改成Response.Write("{name: 'newName'}");了,为什么页面还是执行了error的代码呢? 那你就写成标准的json 试试。{"name":"zhangsan"} 现在我的ajax代码是这样的:$.ajax({ type: "post", url: "login.aspx?action=add", data: $("#loginForm").serialize(), contenttype: "application/json", dataType: "json", success: function (data) { alert(data); }, error: function (err) { alert('出错了'); } }); 后台代码是这样的:if (Request["action"] == "add") { string bbb = Request["usercode"]; string ccc = Request["password"]; Response.ContentType = "application/json"; Response.Write("{'name':'zhangsan'}"); Response.End(); }还是执行了error的代码,求助啊!!!! json 格式。错误改成 "{\"name\":\"zhangsan\"}" asp.net如何传递带#号的参数 求详细解释整条sql语句 ASP.NET Web 应用程序如何做安装项目? 求HTML提出图片地址的正则表达式 怎么给NET的页面引入CSS文件? 这个排列该如何做?谢谢帮忙 请教一个写法 帮忙解决,有分送! 一个很奇怪的问题,紧急求助!!!!!! 动态生成label怎么指定宽度? web可视化工作流设计 请问下现在网站大批量发送邮件一般采取什么方案
{"name":"zhangsan"}
type: "post",
url: "login.aspx?action=add",
data: $("#loginForm").serialize(),
contenttype: "application/json",
dataType: "json",
success: function (data) {
alert(data);
},
error: function (err) {
alert('出错了');
}
}); 后台代码是这样的:
if (Request["action"] == "add")
{ string bbb = Request["usercode"];
string ccc = Request["password"];
Response.ContentType = "application/json";
Response.Write("{'name':'zhangsan'}");
Response.End();
}还是执行了error的代码,求助啊!!!!
改成 "{\"name\":\"zhangsan\"}"