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!

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) jQuery and AJAX Introducing jQuery

Ciprian Micula
Ciprian Micula
5,703 Points

Is what we are doing with AJAX requesting html files in work space the same as if i used a script tag? plz clarify.

I'm not sure whats different between using a script tag in the body or head of the html file or using ajax to request them. Or is this strictly for demonstration purposes and this is supposed to emulate a server?

1 Answer

Neil McPartlin
Neil McPartlin
14,662 Points

I'm just learning about this myself but let me share 2 learnings that may help you with your question.

  1. AJAX is written in JavaScript or JQuery. If the resulting JavaScript code is small, it can be written inside script tags of the index.html file like shown in this video. But if the JavaScript code runs to many lines, it can be stored in its own .js file and reference to that file is entered between the aforementioned script tags in the associated index.html file.

  2. AJAX needs to run on a server. Treehouse 'Workspaces' provides us with a server. Alternatively there are several ways you can configure a local server on your own computer. But trying to use AJAX to communicate between static files on your own computer will not work.