title: XMLHttpRequest.responseText doesnt write the value when calling a URL
body: <p>There may be a small error in my code. please advice me. </p>
  
  <p>I want to call a URL and display the value in div on pageload.I wrote this code from SO but the responseText doesnt write the value in the div element's innerhtml</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>&lt;script type="text/javascript" &gt;    
   var req ;
  // Browser compatibility check          
  if (window.XMLHttpRequest) {
     req = new XMLHttpRequest();
      } else if (window.ActiveXObject) {
  
   try {
     req = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
  
     try {
       req = new ActiveXObject("Microsoft.XMLHTTP");
     } catch (e) {}
   }
  
  }
  
  
  var req = new XMLHttpRequest();
  req.open("GET", "www.example.com/Default.aspx?usrname=john",true);
  req.onreadystatechange = function () {
      document.getElementById('divTxt').innerHTML = "My Status: " + req.responseText;
  }
  
  req.send(null);
  &lt;/script&gt;
   &lt;html&gt;
   &lt;head/&gt;
   &lt;body&gt;
   &lt;div id="divTxt"&gt;&lt;/div&gt;&lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <blockquote>
    <p>The output I get is<br>
     My status : </p>
  </blockquote>
  
  <p>PS: I want this to be done after pageload and The url returns a value "online" when called manually</p>
  
  <p><strong>EDIT</strong> 
  This is the code I referred : <a href="https://stackoverflow.com/questions/906876/call-a-url-from-javascript">code</a></p>