php – jQuery – GET News.html 404(找不到)
由于某种原因,这不行:
$.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)工作正常. 此外,它也不会在我的access.log文件中显示为请求的URL. 有关信息,我猜,我正在运行: lighttpd 并取消注释(在/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 …这是奇怪的说最少.. 卷曲测试 curl 'http://127.0.0.1/News.html' -H 'Accept-Encoding: gzip,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 # 配置文件 > lighttpd.conf 错误日志和什么不 > lighttpd-error.log 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')],'<html>nt<head>ntt<title>test php</title>nt</head>n<body>nChecking</body>n</html>','') 和Here’s the source 给我一个结论,这实际上是一个PHP问题(甚至我讨厌lighttpd不尊重200代码PHP应该回应..对于我很抱歉,应该去PHP一点点,看看如果这有助于我得出结论) 临时解决方案 将以下内容放在.php页面的顶部可以解决这个问题. <?php header("HTTP/1.0 200 Found"); ?>
这有点像同源政策问题.
您指定的路径可能会导致问题. 尝试 $.ajax({ url: "/News.html",}).done(function(data) { $("#content").load(data); }); 让我(我们)知道是否有帮助. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |