.net中cs页面传值到aspx中,怎么用jquery ajax 接收?

function aa() {
$.ajax({
type: 'post',
url: 'WebForm1.aspx.cs',
data: 'string',
dataType: 'text',
async: false,
success: function(msg)
用什么方式把后台的值赋到msg中啊!

第1个回答  2013-09-05
你url那里写错了。
$.ajax({
type: "POST",
url: “WebForm1.aspx / 方法名",
data: {},
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (msg) {
if (msg.d != 0) {
}追问

url指向的是WebForm1.aspx.cs下的方法名嘛?假设是aa方法,应该怎么写啊,小弟是才学ajax有点不太懂

追答

下面的方面名, 你总得告诉他是哪个方法名吧。 你这样写容易出错的。 我那是标准学法。

本回答被提问者采纳
第2个回答  2013-09-05
使用 response.Write()
不过有更简单的写法

$.get("WebForm1.aspx?id=xxx&name=xxx",function(data)
{
var result=eval(data)// 这就是返回来的值

做其他处理

})

后台 就是
string id =request.querystring["id"]
string name =request.querystring["name"];
response.Write("传到前台的值");
response.end();
第3个回答  2013-09-05
Response.Write("2b");
Response.End();
第4个回答  2013-09-05
相似回答