Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial



hey i am using xampp first time on my pc and when i try to make a AJAX request i got an error in console . Error : "XMLHttpRequest cannot load file:///C:/xampp/htdocs/example.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource."

3 Answers

How are you doing your AJAX call in your JavaScript? This is a normal security measure in place to prevent certain types of security issues. Also, how are you accessing your site, is there a site.dev url?

Jeff Lemay
Jeff Lemay
14,268 Points

Start up the Apache server in Xampp and then go to localhost/example.html (or whatever your file is inside your htdocs folder).

Is your ajax call going to that page as well? Can you post a copy of your code?

Jeff Lemay
Jeff Lemay
14,268 Points

Just want to clarify a bit for OP, the whole reason you have Xampp is so you can run a local server. If you are working off C:/xampp/htdocs/, you're not using xampp. You should be using localhost (which is basically C:/xampp/htdocs/ but gives you extra functionality).


would now be


       var ajaxRqst = new XMLHttpRequest();
       ajaxRqst.onreadystatechange = function(){
                   document.getElementById("go").innerHTML = ajaxRqst.responseText;

    <!--ajax request-->
    <div id="go">
<!--requested page-->
<h1>Hello you make a ajax request </h1>

after adding ajaxRqst.open("GET","http://localhost/example.html"); this error caught by a browser console :- GET https://localhost/example.html net::ERR_CONNECTION_REFUSED