【发布时间】:2010-03-11 05:21:42
【问题描述】:
我正在编写一个自定义 Web 服务器。当我在浏览器中输入我的服务器的 URL 时,我得到了我在浏览器中正确写入套接字的示例文本。这是我写的 HTTP 响应:
HTTP/1.1 200 OK\r\n
Server: My Server\r\n
Date: Blah\r\n
Content-Type: text/plain\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.
但是,如果我使用 Ajax (jQuery) 访问相同的 URL,然后在 HTML 页面上设置元素的 innerHTML,我不会打印任何数据。是否需要在我的网络服务器上设置任何其他标头,以便浏览器的 XMLHttpRequest 对象检测到响应?
【问题讨论】:
-
感谢您的链接,@S.Mark:developer.mozilla.org/En/… 使用 firebug 查看此示例中的实际标题:arunranga.com/examples/access-control/preflightInvocation.html
标签: ajax http http-headers xmlhttprequest webserver