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

JavaScript AJAX Basics (retiring) Programming AJAX Introducing the Project

Daniel Sousa
Daniel Sousa
11,975 Points

Ajax and web servers

The end of the last video mentioned that Ajax requests won't work unless you load your webpage through a web server, but when I open my webpages up on Chrome, the ajax requests do work. Am I not understanding something?

4 Answers

Waldo Alvarado
Waldo Alvarado
16,322 Points

Daniel, here is the solution in the video below: https://teamtreehouse.com/library/setup-your-local-development-environment

In it Alena Holligan shows you how to install MAMP and how to configure it to set up one of the folders on your computer as a local web server. Once you have MAMP up and running, simply put your code into an index.html file in the folder you have specified as your server and then in your browser type in http://localhost/ and it should pop up and run the AJAX request.

Leslie Wolfe
Leslie Wolfe
8,700 Points

This is an old question, but if you do try to run requests locally, I recently figured out that Chrome has a security issue and you must use "http://localhost" instead of just "localhost" to for AJAX to work. Otherwise, it will work in Safari.

Same here. Made a simple wikipedia app a while ago and everything worked with no problem. Probably a change in technology or something.

Ana Luiza Barreto Marinho
Ana Luiza Barreto Marinho
2,210 Points

Nope... I'm using MAMP (which is good for windows too) and Webstorm. I've left a comment in one of the videos before explaining how I did that :).