如何用jquery $.ajax向aspx页面传递json格式数据

2024-12-14 11:08:26
推荐回答(2个)
回答1:

处理业务数据,产生JSon数据.代码如下:

protected void Page_Load(object sender, EventArgs e)
{
string u = Request["UserName"];
string p = Request["Password"];
string output = string.Format("'UserName':'{0}','Password':'{1}'", u, p);

Response.Write("[{");
Response.Write(output);
Response.Write("}]");
Response.End();
}
详细:http://www.veryhuo.com/a/view/14293.html

回答2:

后台返回值后,$.ajax中sucess会接收
success:function(d){
var datas=eval('('+d+')');
var s="";
for(var i=0;i s+=datas[i]["contex"]+datas[i]["Number"];
}
alert(s);
}