title: XMLhttpRequest with a node js server with express
body: <p>for a reason that i don't know i can't use the xmlhttprequest in my local server created in node js and express. Let me show you...
  Here is the server in node JS:</p>
  
  <pre><code>var 
  express = require('express'),
  app = express.createServer();
  
  app.get('/count', function(req, res) {
      res.type('text/plain');
      res.write('Hello!')
       res.end();
  });
  
  app.listen(4003);
  </code></pre>
  
  <p>And it runs jus fine! when i acess localhost:4003/count i see "Hello!".</p>
  
  <p>Now that the server is O.K, let's check the html page:</p>
  
  <pre><code>&lt;script&gt;
  
  var xmlhttp = new XMLHttpRequest();
  var resp = ""
  xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200){
          resp = xmlhttp.responseText;
          }
  }
  
  var cam = "localhost:4003/count"
  
  
  function show(){
      xmlhttp.open("GET",cam,  true);
      xmlhttp.send();
      alert(resp);
  }
  
  &lt;/script&gt;
  
  &lt;center&gt;&lt;h1&gt;&lt;div style="color:#339966"&gt; &lt;input type="button" value="Return of /count" onclick="javascript:show()"&gt; &lt;/div&gt; &lt;/h1&gt;
  </code></pre>
  
  <p>So, it just don't work =[, i've already tried to:</p>
  
  <ul>
  <li>change <code>localhost:4003/count</code> as value of the variable <code>cam</code>, for <code>http://localhost:4003/count</code>, <code>127.0.0.1:4003/count</code>.</li>
  <li>Open in Firefox, Safari and Chrome.</li>
  <li>When i try to see the <code>xmlhttp.status</code> with an <code>alert()</code> it shows '<code>0</code>'. (but the page open normally in any browser)</li>
  </ul>