AJAX HTTP response issue with custom server
I started adding HTTP support to a custom non-C # webserver application that seems to work fine with Firefox / IE / Chrome when entering a URL directly into the browser - wherever I see the returned text string in pages from mine applications.
The problem is I am trying to do the same from HTTPRequest in JavaScript on a web page. I am not getting a response from Chrome or Firefox (this is fine in IE) - rather, I am getting a status of zero from the HTTPRequest object, However, I can see that my application, from its debug output, received a request from the browser and provided a response so that the browser does not look like the answer I post in this case, except IE is less picky.
I swapped between trying different POST and GET requests to no avail - e.g .:
request.open ('GET', url, true); request.onreadystatechange = mycallback; //request.setRequestHeader('Content-type ',' application / x-www-form-urlencoded '); request.send (null); // tried '' and other data with POST
Simplest server response I've tried:
HTTP / 1.1 200 OK \ r \ n Content-Length: 20 \ r \ n Content-Type: text / plain \ r \ n \ Y \ n ...........
I tried 1.0 instead of 1.1, different headers like Connection: Close, Accept-range and other random stuff as I tried to mimic other similar answers I was looking at with Wireshark.
Obviously it should be something simple, but the magic combination eludes me!
Thank you very much in advance.
a source to share