Cross-search query for local file

I need to open a local html file in a browser. Javascript works fine, but ajax stops working and XMLHttpRequest gives cross origin error. Is there a way to run ajax from a local directory. I need it to run only from a local file.

thank

+3


source to share


2 answers


For those who want to know, I had to start a server in the application to serve the js files. It looks like it can't be done without starting the server. If anyone knows differently, please tell me.



0


source


If you are using chrome try this extension

CORS allows web applications in one domain to make AJAX requests on a cross-domain to another domain. It's dead just to be included, but only one response header is required to be sent by the server.

What this extension does is add a response header rule - Access-Control-Allow-Origin: *



You can do it manually as well by submitting a response header.

For simple CORS requests, the server needs to add the following header to the response: Access-Control-Allow-Origin: *

Read this one for more information.

-2


source







All Articles