[ale] OT: XMLHTTP + IE
Jay Loden
jloden at toughguy.net
Thu Dec 14 23:27:01 EST 2006
Christopher Fowler wrote:
> It appears that the alarm_check.pl program is never called. I've got
> the program dumping to a log file when it is executed and I see that log
> file updated every 2 seconds when I access this page in netscape. In
> Windows I see nothing. I've used alert() to validate that we are
> getting to that part of the code so I know req.open() is getting called.
> But nothing is happening. Apache log files also show no attempt by IE
> to "GET" the alarm_check.pl program. No JS error messages in IE either.
Here's the code I've used when testing using javascript to pull pages from the server.
It's mostly borrowed from someplace I found online, I forget where. The "getStatus"
function is what gets called from the html page. Maybe you can compare the code and see if
there's something obviously different that would cause a problem.
-----
* Open a connection to the specified URL, which is
* intended to respond with an XML message.
*
* @param string method The connection method; either "GET" or "POST".
* @param string url The URL to connect to.
* @param string toSend The data to send to the server; must be URL encoded.
* @param function responseHandler The function handling server response.
*/
function xmlOpen(method, url, toSend, responseHandler){
if (window.XMLHttpRequest){
// browser has native support for XMLHttpRequest object
req = new XMLHttpRequest();
} else if (window.ActiveXObject){
// try XMLHTTP ActiveX (Internet Explorer) version
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if(req){
req.onreadystatechange = responseHandler;
req.open(method, url, true);
req.setRequestHeader("content-type","application/x-www-form-urlencoded");
req.send(toSend);
} else {
alert('Your browser does not seem to support XMLHttpRequest.');
}
}
function getStatus(){
xmlOpen("GET", "http://jayloden.com/cgi-bin/somescript.cgi", null, myHandler)
return true;
}
function myHandler(){
//write something to the page or whatever
}
More information about the Ale
mailing list