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.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html lang="en" dir="ltr" >
<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"  />
<script type="text/javascript" >
var myform = new MyForm('myform');
<h1 style="font-family: arial" >Elements Status</h1>
<p id="formsParId" >
<body onload="printList()" >

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:

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

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


function MyForm(name){
  function 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!