Hello,
I am an AJAX beginner. I am seeing the following problem when I try to call a function with http_request.onreadystatechange.

Problenm description: I have the following simple HTML where I create a new MyForm object.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html lang="en" dir="ltr" >
<head>
<script src="http://lxplus012.cern.ch:1972/temporary/WebLib.js" ></script>
<link type="text/css" href="http://lxplus012.cern.ch:1972/temporary/style.css" rel="stylesheet"  />
<meta http-equiv="pragma" content="no-cache"  />
</head>
<script type="text/javascript" >
var myform = new MyForm('myform');
</script>
<h1 style="font-family: arial" >Elements Status</h1>
<p id="formsParId" >
</p>
<body onload="printList()" >
</body>
</html>

Then I have my WebLib.js javascript where I have several functions: one of them is the printList() function and the other is the AJAX function which uses onreadystatechange:

Code:
 function makeHttpRequest(url) 
{
  http_request = false;
  if (window.XMLHttpRequest) 
  { 
    http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType)
    {
      http_request.overrideMimeType('text/xml');
    }
  }
  if (!http_request) 
  {
    alert('Giving up :( Cannot create an XMLHTTP instance');
  }

  http_request.onreadystatechange = function() {printList();};
  http_request.open('GET', url, true);
  http_request.send(null);

  return;
}

////////////////////////////////
function MyForm(name){
  this.name=name;
 MyForm.list[name]=this
};
/////////////////////////////////////////////
  function printList(){
 	 alert("printList");
        for(var i in MyForm.list){
 	 alert("Found form i="+i);
        }
    }

My problem is that if I call printList() from my HTML using onload="printList()" then everything is fine and my MyForm.list if not 0 , i.e. I get the alert("Found form i="+i);
If I get rid of the call to printList() in HTML and I do it by calling makeHttpRequest(url)
(this is linked to a button on my web page) then it does not find anithing in MyForm.list, i.e. I only get to the first alert alert("printList"); Is there a way to seolve this without having to put "var myform = new MyForm('myform');" in my WebLib.js? Can anybody help?

Thanks in advance!
Lore