JQuery Ajax发布到C#

我正在尝试在C#上检索JSON对象这里是我的JavasSciprt帖子但是我无法在代码隐藏上进行处理,谢谢!
$.ajax({
    type: "POST",url: "facebook/addfriends.aspx",data: { "data": response.data },contentType: "application/json; charset=utf-8",dataType: "json",success: function (msg) {
        location = '/facebook/login?URL=' + ReturnURL + '&UID=' + response.authResponse.userID + '&TK=' + response.authResponse.accesstoken + '';
    }
});

我试图检索如下数据:

Request.Form["data"]
Request["data"]

解决方法

这是 Encosia.com一个例子(我添加一个表单参数).您不需要访问Page.Form – 您可以使用方法参数.

代码隐藏

public partial class _Default : Page 
{
  [WebMethod]
  public static string GetDate(string someParameter)
  {
    return DateTime.Now.ToString();
  }
}

使用Javascript

$(document).ready(function() {
  // Add the page method call as an onclick handler for the div.
  $("#Result").click(function() {
    $.ajax({
      type: "POST",url: "Default.aspx/GetDate",data: {someParameter: "some value"},success: function(msg) {
        // Replace the div's content with the page method's return.
        $("#Result").text(msg.d);
      }
    });
  });
});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...