I am working on a web application in which I need to call the cgi server, which in turn will use this data for future reference. It works fine in IE6 + and FF, but not in Chrome 15. (not tested with IE6 yet) Here is my code:
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(); }
And the getXMLHttpRequest () function:
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; }
Any solutions? Thanks in advance...
Ved
source share