I am building small offline web app using HTML and JavaScript. CSV file is used to store data.
To read CSV (using jquery-csv library) file I use following code.
<script>
$(document).ready(function(){
var filepath = 'data.csv';
var data_string = $.get(filepath);
});
</script>
But I can't read it because of following error.
XMLHttpRequest cannot load file:///C:/Users/Nimal/Desktop/javascript-csv/data.csv. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https
Then, I found many related articles from here.
- "Cross origin requests are only supported for HTTP." error when loading a local file
- XMLHttpRequest cannot load file. Cross origin requests are only supported for HTTP
- Ways to circumvent the same-origin policy
But I could not find a way to solve my problem. I don't want to use web server. How do I load that CSV file to get data without error(error mean same-origin policy issue)?