我感覺完全愚蠢,因爲我花了兩個小時解決任務應該是非常簡單的,而我之前解決了很多次。但現在我甚至不知道在哪個方向挖掘。ajax(或206部分內容)中的空響應身體
我無法從本地服務器(Apache和Mongrel)使用ajax獲取靜態內容。我得到響應200和206(取決於服務器),空的響應文本(儘管Content-Length標題總是正確的),螢火蟲以紅色顯示請求。
JavaScript是非常通用的,我甚至及彼相同的結果:http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first (只需更改文件位置「http://localhost:3000/whatever」) 因此,它可能不是原因。
那麼,現在我沒有想法。如果它有幫助,我也可以發佈http頭文件。
謝謝!
Response Headers
Connection close
Date Sat, 01 May 2010 21:05:23 GMT
Last-Modified Sun, 18 Apr 2010 19:33:26 GMT
Content-Type text/html
Content-Length 7466
Request Headers
Host localhost:3000
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Referer http://www.w3schools.com/ajax/tryit_view.asp
Origin http://www.w3schools.com
Response Headers
Date Sat, 01 May 2010 21:54:59 GMT
Server Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 mod_jk/1.2.28
Etag "3d5cbdb-fb4-4819c460d4a40"
Accept-Ranges bytes
Content-Length 4020
Cache-Control max-age=7200, public, proxy-revalidate
Expires Sat, 01 May 2010 23:54:59 GMT
Content-Range bytes 0-4019/4020
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Content-Type application/javascript
Request Headers
Host localhost
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Origin null
修訂:
我發現一個問題,它是關於跨域請求。我知道有限制,但認爲他們對本地文件系統和本地服務器放鬆。 (並且期望更多的描述性錯誤信息,無論如何)
謝謝大家!
謝謝你的頭,但JavaScript代碼本身將是最有用的。 – icio 2010-05-01 22:12:05
它甚至可以成爲我提到的w3schools的例子。你去那裏,改變'ajax_info.txt'到你的本地網址,按'編輯並點擊我',然後'更改內容'。現在你可以在螢火蟲中看到請求。 – 2010-05-01 22:44:22
如果您自己解決了問題,那麼在Stack Oveflow中顯示的解決方案的首選方法是將解決方案編寫爲答案,然後將答案標記爲已接受。這也會阻止你的問題出現在「未答覆」頁面。 – 2010-05-02 13:30:02