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 AJAX Concepts A Simple AJAX Example

Ajax , creating an XHR object

Hello,

I was just wondering why we create the XHR object in the html file between the <script> tags ? , isn't it more clean to code html ,css and javascript separe from each other?

1 Answer

Steven Parker
Steven Parker
231,269 Points

Separating JavaScript from HTML is certainly a "best practice" for production code. But inline scripts can be handy for testing, experimentation, or a quick demonstration.

I'm sure this demo isn't intended as a model for production development practices.