我试图使用ajax请求获取运行在Windows Wamp服务器上的"http://localhost/"
的内容。
这个脚本是从如下路径运行的:
file:///C:/my/path/index.html
我只是使用了标准的$.ajax请求来尝试获取localhost的内容:
$.ajax({
type: 'GET',
url: 'http://localhost/',
success: function(data) {
alert('success');
}, error: function (data) {
alert('failed');
}
});
不过我无法成功......似乎是本地文件系统或其他问题。我也不太确定。
Uncaught TypeError: Property 'responseText' of object #<Object> is not a function
当我尝试使用http://时,也会出现这个错误XMLHttpRequest cannot load http://localhost/. Origin null is not allowed by Access-Control-Allow-Origin.
- Emmanuelfile:///
URL发起AJAX请求时,Chrome会给出第二个错误提示。 - lonesomeday