Node.js receives POST request yet gives client side error

I am successfully sending POST requests to a node.js server running on port 8080 via AJAX:

$.ajax({
    url: 'http://127.0.0.1:8080',
    type: 'post',
    dataType: 'text',
    data: 'test'
});

I than can read and work with the data server side using event listeners on the request:

request.setEncoding('utf8');

request.addListener('data', function(chunk) {
   console.log(chunk);
});

request.addListener('end', function() {
   response.end();
});

However I still get an error on my client side like the AJAX call was unsuccessful. The error I get is:

XMLHttpRequest cannot load http://127.0.0.1:8080/. Origin http://127.0.0.1 is not allowed by Access-Control-Allow-Origin.

I also noticed that there is no response and the headers are missing as well.

From which page are you sending the ajax requests? It needs to be on the same domain as the server - try using a relative URL and hosting the client page on the same server and port.