我正在嘗試執行ajax請求以獲取在Windows Wamp服務器上運行"http://localhost/"
的內容。來自本地文件系統的jQuery Ajax請求(Windows文件:///)
劇本是從運行的東西像這樣:
file:///C:/my/path/index.html
我只是用一個標準的$就請求,試圖讓本地主機的內容:
$.ajax({
type: 'GET',
url: 'http://localhost/',
success: function(data) {
alert('success');
}, error: function (data) {
alert('failed');
}
});
我不能讓它成功,雖然...似乎是本地文件系統或某事的一些問題。我不太確定。
試試'/'爲url,然後試試'/ index.html' – 2011-03-29 07:54:28
不可以,這兩者都不能工作 – Emmanuel 2011-03-29 08:04:34
你能直接訪問url嗎?你在js控制檯中遇到錯誤嗎? – 2011-03-29 08:06:16