我有html页面。按下提交按钮后,请求正在发送。我的问题是请求的标头被小写了!我使用 IE 是因为它是公司的限制。
<html>
<head>
<script language="JavaScript" type="text/javascript">
function AjaxRequest(url,callback,method){
var req = new XMLHttpRequest();
req.onreadystatechange= function(){
if(req.readyState != 4) return;
callback(req);
}
req.open(method,url,true);
var hdrsArr = document.getElementById('headers').value.split('&');
for (var i = 0; i < hdrsArr.length; i++){
var p = hdrsArr[i].split('=');
req.setRequestHeader(p[0],p[1]);
}
var params = document.getElementById('params').value ;
req.send(params);
}
function AjaxResponse(res){}
function MakeRequst(){
alert('');
var url = "http://localhost:8080/test-servlet/TestServlet";
AjaxRequest(url,AjaxResponse,"POST");
}
</script>
</head>
<body>
<input type='text' id="headers" size="200" value='key=value&SOAPAction=requestCreditBureau&Content-Type=text/xml;charset=UTF-8&Accept=text/xml'/><br>
<input type='text' id="params" size="200" value='<?xml version="1.0" encoding="UTF-8"?><CB_Document appl="00000000000127725161" >[....]</CB_Document>'/><br>
<input type='button' value='doPost' onClick="MakeRequst();"/><br>
<div id="response_div"></div>
</body>
</html>