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

Andrew Fox
21,899 PointsAjax Challenge
I'm not sure what I'm missing here after looking at this two different times with a break in between...
var request = new XMLHttpRequest(); request.onreadystatechange = function () { if (request.readyState === 4) { document.getElementById("footer").innerHTML = request.responseText; } request.open('GET', 'footer.html'); };
2 Answers

Andrew Fox
21,899 PointsI know that I've managed to confuse myself by building something more complicated during the lesson using Jquery
var $ajax = document.getElementById('ajax');
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4){
$ajax.innerHTML = xhr.responseText;
}
};
$('#load').click(function(){
xhr.open('GET', 'sidebar.html');
xhr.send();
$('#load').hide();
});

Kristen Law
16,244 PointsThe request.open('GET', 'footer.html');
should go outside the function definition. See the video at around 7:25 for more detail.
The first task should look like the following:
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState === 4) {
document.getElementById("footer").innerHTML = request.responseText;
}
};
request.open('GET', 'footer.html');

Andrew Fox
21,899 PointsI appreciate your response and I thought I tried that BUT....maybe not! Thanks!