title: loading xml with javascript
body: <p>I am trying to run the sample code on W3School
  <a href="http://www.w3schools.com/xml/xml_to_html.asp" rel="nofollow">http://www.w3schools.com/xml/xml_to_html.asp</a></p>
  
  <p>I copied the html+js codes and saved into a html file.
  I also downloaded their cd_catalog.xml and put it right beside the html file.</p>
  
  <p>But when I run the html on Chrome, it shows nothing. It is also not working on IE.</p>
  
  <p>Seems the problem is on the line "xmlhttp.send()", because I tried to put an alert right before it, the alert showed, but if I put the alert after that line, then it won't show up.</p>
  
  <p>Anyone can help please?</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;script type="text/javascript"&gt;
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  xmlhttp.open("GET","cd.xml",false);
  alert("before");
  xmlhttp.send();
  alert("after");
  xmlDoc=xmlhttp.responseXML; 
  
  document.write("&lt;table border='1'&gt;");
  var x=xmlDoc.getElementsByTagName("CD");
  for (i=0;i&lt;x.length;i++)
    { 
    document.write("&lt;tr&gt;&lt;td&gt;");
    document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
    document.write("&lt;/td&gt;&lt;td&gt;");
    document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
    document.write("&lt;/td&gt;&lt;/tr&gt;");
    }
  document.write("&lt;/table&gt;");
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the xml file is on <a href="http://www.w3schools.com/xml/cd_catalog.xml" rel="nofollow">http://www.w3schools.com/xml/cd_catalog.xml</a></p>