jQuery AJAX Call for posting data to ASP.Net page ( not Get but POST)
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:
- The content-type should be left out of your jQuery ajax call Or if you want to include it then it should not be 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.Net page the type of data that is being sent, and not the type of data that is expected of the page.
- The data part of jQuery ajax should not have the data names enclosed in quotes. So data: {"venorId":"AD231","businessUnit":"123"} should be replaced by data: {vendorId:"AD231",businessUnit:"123"}. In this example the data names are vendorId and businessUnit, which can be accessed in your ASP.Net code-behind using usual ASP.Net syntax like Request["vendorId"] and Request["businessUnit"].
转自: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)的更多相关文章
- Uploading File using Ajax and receiving binary data in Asp.net (C#)[转]
基础知识,可由此衍生.原文:http://uniapple.net/blog/?p=2050 In this post, I will show you how to upload a file us ...
- 练习 jquery+Ajax+Json 绑定数据 分类: asp.net 练习 jquery+Ajax+Json 绑定数据 分类: asp.net
练习 jquery+Ajax+Json 绑定数据
- JQuery ajax url传值与data传值的区别
url传中文,乱码,即便charset为 UTF-8, $.ajax({ type: "POST", cache: false, url: "/Prod ...
- Jquery Ajax调用aspx页面方法
Jquery Ajax调用aspx页面方法 在asp.net webform开发中,用jQuery ajax传值一般有几种玩法 1)普通玩法:通过一般处理程序ashx进行处理: 2)高级玩法:通过as ...
- jquery ajax jsonp跨域调用实例代码
今天研究了AJAX使用JSONP进行跨域调用的方法,发现使用GET方式和POST方式都可以进行跨域调用,这里简单分享下,方便需要的朋友 客户端代码 复制代码 代码如下: <%@ Page Lan ...
- jquery.ajax请求aspx和ashx的异同 Jquery Ajax调用aspx页面方法
1.jquery.ajax请求aspx 请求aspx的静态方法要注意一下问题: (1)aspx的后台方法必须静态,而且添加webmethod特性 (2)在ajax方法中contentType必须是“a ...
- jQuery学习之jQuery Ajax用法详解
jQuery Ajax在web应用开发中很常用,它主要包括有ajax,get,post,load,getscript等等这几种常用无刷新操作方法,下面我来给各位同学介绍介绍. 我们先从最简单的方法看起 ...
- jQuery学习之jQuery Ajax用法详解(转)
[导读] jQuery Ajax在web应用开发中很常用,它主要包括有ajax,get,post,load,getscript等等这几种常用无刷新操作方法,下面我来给各位同学介绍介绍.我们先从最简单的 ...
- [转]Jquery Ajax用法
原文地址:http://www.php100.com/html/program/jquery/2013/0905/6004.html jQuery学习之jQuery Ajax用法详解 来源: 时间 ...
随机推荐
- HttpRequest类
一.HttpRequest的作用 HttpRequest的作用是令到Asp.net能够读取客户端发送HTTP值.比如表单.URL.Cookie传递过来的参数. 返回字符串的那些值就不说了,那些基本上都 ...
- Codeforces Round #276 (Div. 1) D. Kindergarten dp
D. Kindergarten Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/proble ...
- 大礼包!ANDROID内存优化(大汇总)
写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上把网上搜集的各种内存零散知识点进行汇总.挑选.简化后整理而成. 所以我将本文定义为一个工具类的文章,如果你在A ...
- 【JavsScript】webapp的优化整理
单页or多页 webapp 现状 优劣之分 网络传输优化 综述 fake页-首屏加速 降低请求数 降低请求量 缓存Ajax/localstorage DOM操作优化 综述 关于页面渲染 减少使用定位属 ...
- 能在你离开时照顾你的宠物的3D打印机器人
您的宠物很可爱吧,您要离开时怎么办?找宠物公司来照顾他们?现在不用了.加拿大大学生推出了其3D打印的宠物机器人PetBot,它能照顾您的宠物,让您远程监控宠物,并能让您和宠物互动. “有 些人认为宠物 ...
- Foundation框架之NSArray、NSDictionary、NSSet及其Mutable类型
Foundation框架之NSArray.NSDictionary.NSSet及其Mutable类型 目录 概述——对Foundation框架集合类的理解 NSArray NSDictionary N ...
- 关于ASP.NET中Button的OnClientClick属性
Button有Click属性和OnClientClick属性,执行顺序上OnClientClick先执行,调用本地脚本,根据返回值确定是否执行Click. 当返回True则执行Click,当脚本错误或 ...
- oc-20-多态
/** 为什么父类可以访问子类继承自父类的方法,但是无法访问子类独有的方法? 1.编译器编译时: 编译器在编译时,只检查指针变量的类型,确定该指针变量类型里面有下面调用的方法,如果有该方法,编译器就认 ...
- js本地图片预览代码兼容所有浏览器
html代码 <div id="divPreview" style="width: 160px; height: 170px"><img id ...
- QQ群信息统计
接口一: 1:QQ群信息统计 地址:http://localhost:8080/webServices/messageSort 注意:连接地址提交的是一个txt文件,返回是一个list的json字符串 ...