[ale] OT: XMLHTTP + IE

cfowler cfowler at outpostsentinel.com
Fri Dec 15 10:46:00 EST 2006


I think I'm giving up with IE on this one.  I've modded my code to
somewhat match your code.  I added an alert("Here") just to see when the
state changes.

--- cut here --- Cut here --- Cut Here --- Cut Here --
var alarm = 0;

function start_alarm() {
  setInterval("check_alarm()", 10000);
}

function check_alarm() {
  var req;
  var xml;
  var new_id;

  req = get_from_server();
  xml = req.responseXML.getElementsByTagName("last_alarm_id")[0];
  new_id = xml.firstChild.nodeValue;
  if(alarm == 0) {
    alarm = new_id;
  } else if(new_id > alarm) {
    alarm = new_id;
    refresh();
  }

  return;
}


function get_from_server() {
  var req;
  req = xmlOpen("GET", "/SC/Test/alarm_check.pl", null, myHandler);
  return req;

}function xmlOpen(method, url, toSend, responseHandler){
  var req;

  if (window.XMLHttpRequest){
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject){
    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.');
  }

  return req;

}

function myHandler() {
  alert("Here!");
}


function refresh() {
  window.location.href =  unescape(windows.location.pathname);
}
--- Cut Here --- Cut Here --- Cut Here --- Cut Here --

In IE  I keep getting the "Here!" message.  But in access_log
I see no request to alarm_detail.pl  None.  So what has changed since it
never ran the CGI?


On Thu, 2006-12-14 at 23:27 -0500, Jay Loden wrote:
> 
> 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
> }
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale




More information about the Ale mailing list