选项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();
}