admin管理员组

文章数量:1289404

I am coding a webapp and i get this kind of errors with chrome :

XMLHttpRequest cannot load file:///C:\Users\Tordah\Desktop\foobar.xml. Cross origin requests are only supported for HTTP. 

&

Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 

I believe i get this error because the HTML file is accessed with file: protocol and not http: protocol which creates patibility issues with XMLHttpRequest (That's a guess). I would like to know if there's any ways of testing my pages using http protocol only with my local machine (because only later in this project i will have access to a server, and therefore the app will only work using http, but for now i would like to be able to test it properly).

Is there any workarrounds that i could do on a local machine and that could with with the three browsers IE, Firefox and Chrome?

Thanks.

I am coding a webapp and i get this kind of errors with chrome :

XMLHttpRequest cannot load file:///C:\Users\Tordah\Desktop\foobar.xml. Cross origin requests are only supported for HTTP. 

&

Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 

I believe i get this error because the HTML file is accessed with file: protocol and not http: protocol which creates patibility issues with XMLHttpRequest (That's a guess). I would like to know if there's any ways of testing my pages using http protocol only with my local machine (because only later in this project i will have access to a server, and therefore the app will only work using http, but for now i would like to be able to test it properly).

Is there any workarrounds that i could do on a local machine and that could with with the three browsers IE, Firefox and Chrome?

Thanks.

Share Improve this question asked Jun 9, 2014 at 15:25 TordahTordah 1653 gold badges3 silver badges8 bronze badges 5
  • Wampserver – adeneo Commented Jun 9, 2014 at 15:26
  • have you tried xampp?? apachefriends/index.html – Bharat karotra Commented Jun 9, 2014 at 15:28
  • I would consider running your own server locally like @adeneo suggested. – Kyle Commented Jun 9, 2014 at 15:28
  • 2 basically, you need to host your files over HTTP by running a server and then using http://localhost instead of file:/// – Alex W Commented Jun 9, 2014 at 15:31
  • Thanky you all this is perfectly what i was missing. Have a good day everyone! – Tordah Commented Jun 9, 2014 at 16:54
Add a ment  | 

2 Answers 2

Reset to default 6

I assume that you didn't install a local server...i suggest you XAMPP, is the best for doing this kind of stuffs...

https://www.apachefriends/download.html

here is the url where you can download it. when you already install it, you have to copy your work into the directory

C:/xampp/htdocs/(here you paste your work)

open your browser and write in the url like this:

http://localhost:8080/(name of your work directory)/(what archive you want to see, better if it has index)

You need to install a web server. You have a bunch of different choices, but since you didn't mention an operating system, I'll suggest XAMPP from https://www.apachefriends/download.html

That will give you an Apache distribution containing MySQL, PHP, and Perl and will run on Windows/Mac/Linux

本文标签: javascriptOpen local html pages using http to testStack Overflow