Question : Checking server status

Hello, I'm trying to have the damnest time try to get this to work... any ideas on why it's not functioning?  probably something stupid I'm just missing...  Thanks for the help here...
jeremyBass
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
function startLoad($source) { 
    req = new XMLHttpRequest();
    req.open('GET', $source, true); 
    req.onreadystatechange=finishLoad; 
    req.send(null); 
} 
 
function finishLoad() { 
    if (req.readyState==4) {   // request is done 
	if (req.status==200) { // "OK"
	var prefix = '';
    if (window.event.ctrlKey) {
         document.test.control.value = 'true';
	}else{
         if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
      document.pageLoading.TCallLabel('/','restart_function');
          }else{
      document.getElementById(divid).style.display = 'none';
    }
	}
	    //var response = req.responseXML; 
//	    var target = document.getElementById('foo'); 
//	    for (var i=0; i link 
Open in New Window Select All

Answer : Checking server status

This:
req.onreadystatechange=finishLoad(divid);

is NOT what I posted. You are calling finishLoad immediately and assigning its returned value to onreadystatechange, which is wrong. You need to assign a function reference:
req.onreadystatechange=function(){ finishLoad(divid); };
Random Solutions  
 
programming4us programming4us