0

Possible Duplicate:
Circumventing Chrome Access-control-allow-origin on the local file system?

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

Community
  • 1
  • 1
mohsin.mr
  • 498
  • 1
  • 6
  • 21

3 Answers3

3

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

This Link for further read.

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

Reference :: Issue in Chrome

Community
  • 1
  • 1
Ashish Gupta
  • 1,651
  • 14
  • 30
2

XMLHttpRequest cannot load file:///F:/shane/autorating.csv. Origin null is not allowed by Access-Control-Allow-Origin. means you are trying to load a local file which is forbidden in chrome. That makes kind of sense as you wouldn't want just any script to go through all you local files. Besides that, there is a way even though you just need to run it on a HTTP-Server. Check out this this.

codingjoe
  • 1,210
  • 15
  • 32
-1

Content-Type must include charset

Content-Type: text/plain; charset=utf-8

Ozerich
  • 2,000
  • 1
  • 18
  • 25