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 trialHeather Cloward
6,506 PointsXMLHttpRequest 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?
1 Answer
Peter Vann
36,427 PointsHi Heather!
These might help:
https://zetcode.com/javascript/xmlhttprequest/
https://www.w3schools.com/js/js_ajax_intro.asp
https://www.w3schools.com/js/js_ajax_examples.asp
https://forum.freecodecamp.org/t/best-resources-to-learn-ajax/4181
Fetch is NEW:
https://www.w3schools.com/js/js_api_fetch.asp
https://www.xul.fr/en/html5/fetch.php
I hope this all helps.
Stay safe and happy coding!
Alsaig Sandra
Front End Web Development Techdegree Graduate 15,434 PointsAlsaig Sandra
Front End Web Development Techdegree Graduate 15,434 PointsI second everything that has been said by Heather Cloward. I'm really struggling due to the lack of information regarding these new/not familiar methods.