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 offile:///
– 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
2 Answers
Reset to default 6I 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
版权声明:本文标题:javascript - Open local html pages using http to test - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741475778a2380874.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论