标签:
the following jQuery AJAX call to an ASP.Net page.
$.ajax({ async: true, type: "POST", url: "DocSummaryDataAsync.aspx", //"DocSummary.aspx/GetSummaryByProgramCount", contentType: "application/json; charset=utf-8", data: kendo.stringify({ vendorId: supplierId, businessUnit: busUnit, productSegmentId: prodSegmentId, programId: progId, productManagerId: prodManagerId, companyIds: compIds, expired: exp.toString(), requestType: ‘TotalCount‘ }), success: function (msg) { // alert(‘in success of getcount‘); }, error: function (XMLHttpRequest, textStatus, errorThrown) { // alert(‘in failure of getcount‘); } });
When I try to retrieve from Request object, the posted data, it does not show up. My aspx page code is as below. I am sending each of posted data in Json format to the page, yet it doesn‘t show up in code-behind of page. Is there some extra setting in jQuery ajax call that I am missing?
protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "application/json"; string requestType = Request.Params["requestType"]; //populate variables from posted data string vendorId = Request.Params["vendorId"]; string businessUnit = Request.Params["businessUnit"]; string productSegmentId = Request.Params["productSegmentId"]; string commitmentProgramId = Request.Params["programId"]; string productManagerId = Request.Params["productManagerId"]; string companyIds = Request.Params["companyIds"]; string expired = Request.Params["expired"]; }
UPDATE 1: Stephen‘s answer is the best approach to this, especially the approach that does ProcessRequest. However, I did find a small trick that will allow data to be posted to ASP.Net in the usual traditional manner i.e. like Request["vendorId"] etc. To enable such posting of data from any jQuery ajax request, you simply need to make sure that the following 2 points are applied to your jQuery ajax call:
转自:http://stackoverflow.com/questions/14095041/jquery-ajax-call-for-posting-data-to-asp-net-page-not-get-but-post
jQuery AJAX Call for posting data to ASP.Net page ( not Get but POST)
标签:
原文地址:http://www.cnblogs.com/wangfuyou/p/5435812.html