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.
Heather Cloward6,356 Points
XMLHttpRequest object event handlers
Having just finished AJAX basics and moving into this course I got very confused about the function written in this code to create the XMLHttpRequest object. It took me a while to realize what was so confusing, but I figured out that there is a method called on the XMLHttpObject that is not used in the AJAX basics course,
xhr.onload. It seems this method is actually an event handler that has been recently added by various browsers? Furthermore, when I went back to the AJAX course I recalled we were told there were 4 steps to creating an AJAX request - 1. create the object, 2. write the callback, 3. open the request, 4. send the request. This code does not create the callback until after opening the request, yet another confusing point. I think it would be helpful if at a minimum a link is included in the teacher's notes to some content on this new method, .onload - as otherwise it is confusing. I found some info on mdm here - https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequestEventTarget/onload - however it was not particularly informative. Perhaps you have access to something better?
These might help:
Fetch is NEW:
I hope this all helps.
Stay safe and happy coding!