How to play around same-origin policy without using server?

279 Views Asked by At

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.

  1. "Cross origin requests are only supported for HTTP." error when loading a local file
  2. XMLHttpRequest cannot load file. Cross origin requests are only supported for HTTP
  3. 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)?

0

There are 0 best solutions below