ajax中post 报400错误get没问题
如题,我通过post向服务器发送请求没有在客户端得到status为400通过get就没有问题!我测试过了,地址肯定是对的,var parameter = "action=showStartTime&random="+Math.random();这个也是没问题的啊!
获取xmlhttprequest如下
function httpRequest(reqType,url,async,resFun,paramter){
var request =null;
if(window.XMLHttpRequest){
request = new XMLHttpRequest();
}else if(window.ActiveXObject){
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if(request||typeof(request)=="object"){
if(reqType.toLowerCase()=="post"){
request.open(reqType,url,true);
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.onreadystatechange=resFun;
parameter = encodeURI(paramter);
request.send(paramter);
}else{
url=url+"?"+paramter;
request.open(reqType,url,true);
request.onreadystatechange=resFun;
request.send(null);
}
}else{
alert("brower do not support AJAX!")}
return request;
}
post方法就是400了
求大神告诉我为啥啊!本人新手