52,797
社区成员
发帖
与我相关
我的任务
分享
$.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'},
提交的javascript的对象有误~ $.ajax({
type: "POST",
url: "contact_story.ashx",
data: { shopname: shopname },
beforeSend: function() {
//do nothing
}
})
后台:
string shopname = context.Request["shopname"];
我一般是这样写的.. 希望对你有帮助吧
//data: "{'str':'我是','str2':'XXX'}",
//==>
data: {'str':'我是','str2':'XXX'},
指定了这个dataType: "json",动态页要返回标准json格式的字符串,要不也会执行error回调
怪异模式的json字符串jquery1.4+也会执行error,需要注意一下