由于某种原因,这不行:
$.ajax({
url: "News.html",
cache: false,
}).done(function(data) {
$("#content").load(data);
});
它给了我
GET http://127.0.0.1/News.html 404 (Not Found)
但无论如何,手动打开该URL(复制粘贴url)工作正常.
我以为它和浏览器缓存有关,所以我添加了缓存:false选项到ajax函数,但即使如此.
此外,它也不会在我的access.log文件中显示为请求的URL.
有关信息,我猜,我正在运行:
lighttpd
> php as fast-cgi via localhost:port
> mapped .html => .PHP
>运行OpenBSD 5.3
并取消注释(在/etc/php.ini中):
> cgi.fix_pathinfo = 1
也:
# ls *.html
News.html index.html
以下是News.html的请求标头:
Request URL:http://127.0.0.1/News.html
Request Method:GET
Status Code:404 Not Found
请求标题
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:127.0.0.1
Referer:http://127.0.0.1/index.php
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36
X-Requested-With:XMLHttpRequest
回应标题
Content-type:text/html
Date:Tue, 16 Jul 2013 21:55:05 GMT
Server:lighttpd/1.4.32
Transfer-Encoding:chunked
X-Powered-By:PHP/5.3.21
检查站
迄今为止的评论结论是,这可能不是一个jQuery的问题.
考虑到服务器响应所有数据(我已经检查发送的原始数据),并且它包含所有内容,但响应标题为404.
意思是说,数据被发现,但标题说404 …这是奇怪的说最少..
卷曲测试
curl 'http://127.0.0.1/News.html' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: 127.0.0.1' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36' -H 'Accept: */*' -H 'Referer: http://127.0.0.1/' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' --compressed
Here you'll soon find a facebook feed, among other things :)
Zerkms测试
# echo "wham bam" > zerkms_doesnt_believe.html
#
配置文件
错误日志和什么不
cURL测试
通过Python客户端手动FastCGI测试:
# python fcgi_app.py
{'FCGI_MAX_CONNS': '1', 'FCGI_MPXS_CONNS': '0', 'FCGI_MAX_REQS': '1'}
经过一些修补,我想出了FastCGI协议如何工作,我发现一个符合我需求的客户端,很有趣,足以匹配我的脚本的名称,所以这里的输出:
# python fcgi_app.py
('404 Not Found', [('x-powered-by', 'PHP/5.3.21'), ('content-type', 'text/html')], '\n\t
\n\t\ttest php\n\t\n\nChecking\n', '')给我一个结论,这实际上是一个PHP问题(甚至我讨厌lighttpd不尊重200代码PHP应该回应..对于我很抱歉,应该去PHP一点点,看看如果这有助于我得出结论)
临时解决方案
将以下内容放在.php页面的顶部可以解决这个问题.
请注意,这是一个干净的解决方法,它将工作,但它不是一个长期的修复肯定.
header("HTTP/1.0 200 Found");
?>