AJAX问题求解
在web窗体的<script>标签中,我写了这样一个方法
function doRequest() {
var request;
var pro = document.getElementById("province");//页面上一个select标签
if (window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
}
if (request) {
request.open("post", "Handler1.ashx");
request.onreadystatechange = callback;
var postData = "proID=" + pro.value;
request.setRequestHeader("content-length", postData.length);
request.setRequestHeader("content-type", "application/x-www-form-urlencoded");
request.send(postData);
}
}
在Handler1.ashx文件的ProcessRequest(HttpContext context)方法中,我用context.Request.QueryString["proID"]来获取前台传入数据,为什么获取的是个null,可郁闷,求解求指导,谢谢
------解决方案--------------------
post方法使用
context.Request.Form["proID"]