Headers to set for AJAX calls in a custom webserver

Posted by ErJab on Stack Overflow See other posts from Stack Overflow or by ErJab
Published on 2010-03-11T05:21:42Z Indexed on 2010/03/11 5:28 UTC
Read the original article Hit count: 817

I'm writing a custom web server. When I enter the URL of my server in the browser, I get the sample text I write out to the socket in my browser correctly. This is the HTTP response that I write:

HTTP/1.1 200 OK\r\n
Server: My Server\r\n
Date: Blah\r\n
\r\n
This is some sample text. This appears in my browser correctly when I connect directly to the server entering the URL.

However, if I use Ajax (jQuery) to access the same URL and then set the innerHTML of an element on the HTML page, I do not get any data printed. Is there any other header I need to set on my web server so that the browser's XMLHttpRequest object detects the response?

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about webserver