0

I made very simple server like

var httpPort = 3001
var http = require('http');

http.createServer(function (req, res) {
        console.log(req.url + " "  + req.method);
        res.writeHead(200, {'Content-Type':'text/plain'});
        res.end('OK');
   }
).listen(httpPort,'127.0.0.1');

I think, the server returns xhr.statusCode 200 and xhr.responseText 'OK'

But, client always read 0 and ''

Do i miss something? or wrong code?

pebC
  • 33
  • 1
  • 2
  • 9
  • 1) have you tried to access it directly without using XHR? 2) Add your client side code - maybe something is wrong there. (I could think of a SOP problem) – Sirko Jul 26 '16 at 07:24
  • This is very likely to be a [duplicate of this](http://stackoverflow.com/questions/35553500/xmlhttprequest-cannot-load-https-www-website-com) but you need to use the Developer Tools in your browser and *read the error messages* in order to find out why you are getting a status 0. – Quentin Jul 26 '16 at 07:25
  • above code looks good and you need to update and check client side code. You should try via curl or postman to test and then try with client side code so that you can identify issue in client side or server side – Arif Khan Jul 26 '16 at 07:28
  • @Sirko client and server are local which are same domain, so i don't think so – pebC Jul 26 '16 at 08:18
  • @pebC "local" in this context also includes the port. In your code you used port 3001, which let me think, that there might be another server serving the static content on port 80. – Sirko Jul 26 '16 at 08:19
  • @Sirko thanks. i resolved it by express and cors plugins – pebC Jul 26 '16 at 23:10

0 Answers0