I am having a problem that is driving me crazy and I am whits end. I am
hoping that someone here can help me. I have a client server application
where the client is drawing a progressive bar graph based on data
retrieved from the server once a second. The basic loop looks like this;
</HEAD>
<script language="JavaS cript1.2">
var nodedatareq;
function buildGraphs() {
document.writel n("<BODY>");
// build graphs and add them
document.writel n("</BODY>");
window.addEvent Listener("resiz e",resizeEventH andler, false);
}
function initXMLHTTPRequ est() {
var xreq= null
if( window.XMLHttpR equest ) {
xreq= new XMLHttpRequest( )
} else if(window.Activ eXObject) {
xreq= new ActiveXObject(" Microsoft.XMLHT TP")
}
return xreq
}
function sendNodeRequest ()
{
var mnodedataod="PO ST";
nodedatareq = initXMLHTTPRequ est();
if( nodedatareq ) {
nodedataParam = "nodedata=" + escape(1)
nodedatareq.onr eadystatechange =nodedataHandle r
nodedatareq.ope n(mnodedataod,s erverURL,true)
nodedatareq.set RequestHeader(" Content-Type",
"applicatio n/x-www-form-urlencoded")
nodedatareq.sen d(nodedataParam )
}
}
function nodedataHandler () {
var ready= nodedatareq.rea dyState
var respStr=null
var index
if( ready == READY_STATE_COM PLETE ) {
respStr=nodedat areq.responseTe xt
// plot data
timer = setTimeout(send NodeRequest, 1000)
}
}
function resizeEventHand ler(target, e)
{
// do nothing
}
buidGraphs()
timer = setTimeout(send NodeRequest, 1000)
</script>
This works fine advancing the graphs and looping until I resize the
window. Once I do that the first time it reenters sendNodeRequest () I
get an error that initXMLHTTPRequ est is undefined. I tried inlining the
code for initXMLHTTPRequ est into sendNodeRequest but then it complains
thay nodedatareq is undefined. It is as if it has completely lost all of
its history and has no context or scope.
I have tried using
window.onresize = function(e) {resizeEventHan dler(e);};
instead of window.addEvent Listener. I tried
window.onresize = function(e) {resizing = 1;};
so it didn't have to call a function, but that had the same results.
I also tried putting the call to window.addEvent Listener before the call
to buildGraphs. Then it didn't die but the event was not seviced either.
Anyone have any suggestions?
Thanks
Howard