C# 无法获取Post数据
JS代码:C# 无法获取Post数据,c#,jquery,C#,Jquery,JS代码: function save( ref, text){ $.post("save.aspx", {cc:"us", ref:ref, text:text}, function(data){ $("[data-ref='"+ref+"'] .loader").animate({opacity:0},500,function(){ $(this).parent().removeClass("sa
function save( ref, text){
$.post("save.aspx", {cc:"us", ref:ref, text:text}, function(data){
$("[data-ref='"+ref+"'] .loader").animate({opacity:0},500,function(){
$(this).parent().removeClass("saving");
$(this).remove();
});
});
}
CS文件代码:
public partial class save : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// $_REQUEST['cc'];
// HttpContext.Current.Response
string strcc = Request.Form["cc"];
string strRef = Request.Form["ref"];
string strtext =Request.Form["text"];
}
}
无法将值从JS代码传递到下一页,我在这里做错了什么?您的代码很好。我几乎可以肯定,ASPX页面代码在JS函数调用它之前执行。你可以用来追踪这一点,如果你把你的帖子参数放在引号之间会发生什么,比如:
{“cc”:“us”,“ref”:ref,“text”:text}
@ashish我认为你放不放引号并不重要。@ashish我也试过了,但没有用fiddler检查过,在IE中,我发现这篇文章HTTP/1.1 Accept:/Content Type:application/x-www-form-urlencoded;charset=UTF-8 X-request-With:XMLHttpRequest Referer:Accept语言:en接受编码:gzip,deflate用户代理:Mozilla/5.0(兼容;MSIE 10.0;Windows NT 6.1;WOW64;Trident/6.0;MDDSJS)主机:localhost:41162内容长度:0 DNT:1连接:保持活动Pragma:no cacheand in Chrome POST HTTP/1.1主机:localhost:41162连接:保持活动内容长度:49接受:/Origin:X-request-With:XMLHttpRequest用户代理:Mozilla/5.0(Windows NT 6.1;WOW64)AppleWebKit/537.36(KHTML,像Gecko)Chrome/34.0.1847.137 Safari/537.36内容类型:application/x-www-form-urlencoded;charset=UTF-8 Referer:Accept编码:gzip,deflate,sdch接受语言:en-US,en;q=0.8 cc=us&ref=msg\u share\u title&text=Sharing+is+caringrChrome能够获取数据,但在IE中没有任何原因?哪个页面正在调用localhost:41162/Admin/save.aspx?您是否在另一个页面或save.aspx上有JS脚本?该脚本位于不同的页面/admin/translate.aspx中