Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.