title: How to get response from webservice URL using JavaScript
body: <p>I am new to Javascripting.
  I have http webservice URL which results in xml respose. how do I get the response xml from the URL. I tried using the following using XMLHttpRequest but no luck.</p>
  <pre><code>function send_with_ajax( the_url ){
      var httpRequest = new XMLHttpRequest();
      //httpRequest.onreadystatechange = function() { alertContents(httpRequest); };  
      httpRequest.open(&quot;GET&quot;, the_url, true);
      httpRequest.setRequestHeader(&quot;Content-type&quot;, &quot;application/x-www-form-urlencoded&quot;);
      httpRequest.setRequestHeader(&quot;X-Requested-With&quot;, &quot;XMLHttpRequest&quot;);
      httpRequest.setRequestHeader(&quot;X-Alt-Referer&quot;, &quot;http://www.google.com&quot;);
      httpRequest.send();
      httpRequest.onreadystatechange = function() { 
          if (httpRequest.readyState == 4)
          {
              var _tempRecommendations = httpRequest.responseXML;
              window.alert(httpRequest.response)
              window.alert(httpRequest.responseText)
              window.alert(_tempRecommendations)
          }
      };  
  };
  </code></pre>
  <p>I always get <code>httpRequest.readyState = 1</code> and also when I evaluate the response in console its all null.</p>