0
我正在开发一个Web应用程序,在这个应用程序中我需要调用服务器cgi,然后将这些数据用于进一步的使用。 它在IE6 +和FF,但无法在Chrome 15(与IE6尚未检查) 这里工作的罚款是我的代码:HTTP-POST XHR不能在chrome中工作
var destinationURL = "/cgi-bin/conf.cgi";
var xmlHttpReq = getXMLHttpRequest();
if(xmlHttpReq == null){
return false;
}
if (xmlHttpReq.readyState == 0){
xmlHttpReq.open('POST', destinationURL, true);
xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpReq.onreadystatechange = function() {
if (xmlHttpReq.readyState == 4) {
alert(xmlHttpReq.responseText);
}
}
xmlHttpReq.send();
}
而且getXMLHttpRequest()函数是:
function getXMLHttpRequest() {
var xmlHttpReq;
if (window.XMLHttpRequest) {
xmlHttpReq = new window.XMLHttpRequest();
}
else {
try {
xmlHttpReq = new window.ActiveXObject("Microsoft.XMLHTTP");
}
catch(ex) {
alert('Exception in initializing the XMLHttpRequest object '+ex.toString());
return null;
}
}
return xmlHttpReq;
}
任何解决方案? 在此先感谢...
我从POST将其改为GET和它的工作... !!! 但是如果我想严格使用POST? – Ved