$ .ajax函数无法读取Chrome中的csv文件 [英] $.ajax function is not reading csv file in chrome

查看:29
本文介绍了$ .ajax函数无法读取Chrome中的csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
绕开Chrome Access-control-allow-origin本地文件系统?

我的问题很简单,我正在使用$ .ajax函数读取CSV文件,并且代码在FF和IE9上有效,但在Chrome中不起作用...

My question is very straight forward, I am using $.ajax function to read a CSV file and the code is working on FF and IE9 but not in Chrome....

<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://code.jquery.com/jquery-1.8.2.min.js">
</script>
<script type="text/javascript">
$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "autorating.csv",
        contentType: "text/csv",
        success: function(data) {alert('asdsa');}
     });
});


</script>
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

任何帮助都将是可贵的...谢谢

Any help will be appreciable... Thanks

推荐答案

您正在读取没有服务器的本地文件.Chrome不允许这样做.

You are reading local file without a server. Chrome doesnt allow this.

此链接以供进一步阅读.

使用-allow-file-access-from-files 作为更安全的解决方法.

Use --allow-file-access-from-files as a safer workaround.

参考:: Chrome中的问题

这篇关于$ .ajax函数无法读取Chrome中的csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆