选项1.保持服务器端代码相同
首先删除kendo.stringify。然后删除contentType或将其更改为…
"application/x-www-form-urlencoded; charset=utf-8"
…或者将$ .ajax调用更改为:
$.post('DocSummaryDataAsync.aspx',{ vendorId: supplierId,requestType: 'TotalCount' },function (data) { });
选项2.将POST更改为GET
喜欢这个
$.ajax({
async: true,type: "GET",etc.
这将通过QueryString传递您的数据。如果你删除kendo.stringify调用,你将访问所有这样的值:
string vendorId = Request.QueryString[0];
string businessUnit = Request.QueryString[1];
etc.
选项3.使用原来的$ .ajax调用
如果您使用原来的$ .ajax,则适用以下条件:
Request.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();
}