asp ajax post get,jQuery AJAX调用将数据发布到ASP.Net页面(不是Get但POST)

选项1 让您的服务器端代码相同的

首先拆下kendo.stringify。然后,要么删除的contentType或将其更改为...

"application/x-www-form-urlencoded; charset=utf-8"

...或者改变您的$就调用此:

$.post('DocSummaryDataAsync.aspx', { vendorId: supplierId, businessUnit: busUnit, productSegmentId: prodSegmentId, programId: progId, productManagerId: prodManagerId, companyIds: compIds, expired: exp.toString(), requestType: 'TotalCount' }, function (data) { });

选项2 更改POST到GET

像这样

$.ajax({

async: true,

type: "GET",

etc.

这将通过将q传数据ueryString。如果删除kendo.stringify叫你将访问所有的值是这样的:

string vendorId = Request.QueryString[0];

string businessUnit = Request.QueryString[1];

etc.

选项3 如果使用原来的$就使用你原来的$就调用

,那么以下适用:

请求。Params获得“QueryString,Form,Cookies和ServerVariables项目的组合集合”。 - this link

你没有与任何这些工作。相反,您需要访问Request.InputStream。

这里是你如何能做到这一点:

创建在服务器端映射到所请求的JSON对象,例如类

public class MyClass

{

// The type (int or string) should probably correspond to the JSON

public int vendorId { get; set; }

public string businessUnit { get; set; }

public string productSegmentId { get; set; }

public string programId { get; set; }

public string productManagerId { get; set; }

public string companyIds { get; set; }

public string expired { get; set; }

public string requestType { get; set; }

}

转换Request.InputStream到该类型,然后你可以使用它。

public void ProcessRequest()

{

System.IO.Stream body = Request.InputStream;

System.Text.Encoding encoding = Request.ContentEncoding;

System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);

string json = reader.ReadToEnd();

JavaScriptSerializer serializer = new JavaScriptSerializer();

MyClass myclass = (MyClass)serializer.Deserialize(json, typeof(MyClass));

int vendorId = myclass.vendorId;

string requestType = myclass.requestType;

// etc...

}

protected void Page_Load(object sender, EventArgs e)

{

ProcessRequest();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值