Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open local html pages using http to test

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 compatibility 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.

like image 623
Tordah Avatar asked Feb 12 '23 18:02

Tordah


2 Answers

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.org/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)
like image 147
MickyScion Avatar answered Feb 15 '23 08:02

MickyScion


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.org/download.html

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

like image 22
NinjaCat Avatar answered Feb 15 '23 09:02

NinjaCat