The following jQuery AJAX call to an ASP.
$.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. The My aspx page code is as below. I am sending each of the posted data in Json format to the page, yet it doesn ' t show on Code-behind of page. is there some extra setting in JQuery Ajax call that I am missing?
protected voidPage_Load (Objectsender, EventArgs e) {Response.ContentType="Application/json"; stringRequestType = request.params["RequestType"]; //populate variables from posted data stringVendorID = request.params["VendorID"]; stringBusinessunit = request.params["Businessunit"]; stringProductsegmentid = request.params["Productsegmentid"]; stringCommitmentprogramid = request.params["ProgramID"]; stringProductmanagerid = request.params["Productmanagerid"]; stringCompanyids = request.params["Companyids"]; stringexpired = request.params["Expired"]; }
UPDATE 1: stephen ' s answer is the best approach to this, especially the approach that does proces Srequest. However, I did find a small trick that would allow data to be posted to ASP. Like R equest["VendorID"] etc. To enable such posting of data from any jQuery Ajax request, you simply need to make sure that the following 2 points is Applied to your jQuery Ajax call:
- The Content-type should is left out of your jQuery ajax call Or If you want to include it and it should not is set to "Application/json; Charset=utf-8 "but to" application/x-www-form-urlencoded; Charset=utf-8 ". Content-type, as per my understanding is telling the ASP. Page The type of data is being sent, and not the type of Data is expected of the page.
- The data part of the JQuery Ajax should is not having the data names enclosed in quotes. So data: {"Venorid": "AD231", "businessunit": "123"} should is replaced by data: {vendorid: "AD231", Businessunit: "123"}. In this example the data names is VendorID and Businessunit, which can accessed in your ASP. Code-behind using Usua L ASP. Syntax like request["VendorID"] and request["Businessunit"].
Transferred from: 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. Page (not Get but POST)