asp.net后台怎么获取ajax提交的数据
本帖最后由 showbo 于 2013-04-20 16:42:44 编辑
$.ajax({
type: "Post",
// url: "WebForm1.aspx/SayHello",
url: "WebForm1.aspx",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{'str':'我是','str2':'XXX'}",
success: function (data) {
//返回的数据用data.d获取内容
alert(data.d);
},
error: function (err) {
alert(err);
}
});
protected void Page_Load(object sender, EventArgs e)
{
string a = Context.Request["str"];
string b = Request["str"];
string c = Request.Form["str"];
string d = Request.QueryString["str"];
}
//data: "{'str':'我是','str2':'XXX'}",
//==>
data: {'str':'我是','str2':'XXX'},
$.ajax({
type: "POST",
url: "contact_story.ashx",
data: { shopname: shopname },
beforeSend: function() {
//do nothing
}
})