-3

I have made a project whose structure is like this

My project structure

When I run my index.html from firefox, it is working fine.

But I open it with my chrome it is giving CORS error. Chrome url

Chrome Error

Now my problem is that chrome doesnot support file:// protocol ajax request & as I have distribute to my project to others I don't want other to run on firefox only.

Internally I am using ajax call in project, to load the resources. Can Somebody suggest how to bypass that ajax call to load resources?? Is there some solution or any third party js which can help me.

Note: Please don't suggest to use XAMPP, apache etc where I can put my project and run as localhost for chrome as I don't want user to force to download these to run my project. Please give other useful solution where I can do some change in code & it works for everyone.

Here are the links from which you could understand my problem better.

Ajax in Jquery does not work from local file

AJAX code do not run locally

AJAX request using jQuery does not work

Community
  • 1
  • 1
Rajan Singh
  • 611
  • 4
  • 9
  • 1
    **Please give other useful solution:** Don't use AJAX. And without even a basic code, how can we provide help? – Praveen Kumar Purushothaman Dec 14 '15 at 11:19
  • 1
    This question makes no sense...I have no idea what your asking – Liam Dec 14 '15 at 11:20
  • @Liam Can you tell me, why we use localhost to run some project ?? May be this will make you more sense!! – Rajan Singh Dec 14 '15 at 11:23
  • Hi @RajanSingh , any solution ? – Sushi May 16 '17 at 09:36
  • Sorry for late comment, @RajanSingh you need to use localhost or upload it in other website because the XMLHttpRequest function is only accepting from "http","https","chrome","chrome-extension-resource" protocols. the "file" protocol is strictly forbidden for security issues. – shunz19 Sep 04 '17 at 02:28

1 Answers1

2

Embed the data directly into the JavaScript or HTML and read it from there.

The data isn't going to be changing based on user input or the contents of a database, so having it in a separate "http" resource doesn't bring huge benefits.

If you want to store the data in XML to make it easier to edit in your development environment, then write a build tool to bundle it up into an embedded format before distributing.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335