title: Getting error message on while AJAX-get on localhost with node.js
body: <p>I'm trying to use AJAX to get a piece of string from a local server made using <code>node.js</code>, the connection is being done, status 200, everything is working but I still can't get the piece of string. May someone provide me an explanation of why this is happening?</p>
  
  <p>P.S.: I'm still a newbie to <code>node.js</code></p>
  
  <p><strong><em><code>Node.js</code> server code:</em></strong></p>
  
  <pre><code>// Load the http module to create an http server.
  var http = require('http');
  
  // Configure our HTTP server to respond with Hello World to all requests.
  var server = http.createServer(function (request, response) {
    response.writeHead(200, {"Content-Type": "text/javascript"});
    response.end("var a = 'Hello World';");
  });
  
  // Listen on port 8000, IP defaults to 127.0.0.1
  server.listen(8000);
  
  // Put a friendly message on the terminal
  console.log("Server running at http://127.0.0.1:8000/");
  </code></pre>
  
  <p><strong><em><code>AJAX</code> Call code:</em></strong></p>
  
  <pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
      $.ajax({
              async: 'false',
              type: 'GET',
              url: 'http://127.0.0.1:8000/',
          success: function(data, textStatus){
              console.log('DONE: Request has been successfully sent');
          },
          error: function(xhr, textStatus, errorThrown){
              console.log('ERR: Request failed \nSTATUS: '+textStatus+'\nERROR: '+errorThrown);
              console.log(xhr);
          }
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Console:</strong></p>
  
  <pre><code>XMLHttpRequest cannot load http://127.0.0.1:8000/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
  
  XHR failed loading: GET "http://127.0.0.1:8000/".send @ jquery-latest.min.js:4m.extend.ajax @ jquery-latest.min.js:4(anonymous function) @ 
  
  ERR: Request failed 
  STATUS: error
  ERROR: 
  
  Object {readyState: 0, responseText: "", status: 0, statusText: "error"}
  </code></pre>