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 trialMary Chadwick
10,683 Points[SOLVED] Am getting "undefined" after I click the buuton
When we preview in Workspaces, is the code supposed to work or should I set up a local server? I've checked my code 3 times and keep getting, undefined, after clicking the button.
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
document.getElementById('ajax').innerHTML = xhr.repsonseText;
}
};
xhr.open('GET', 'sidebar.html');
function sendAJAX() {
xhr.send();
document.getElementById('load').style.display = "none";
}
</script>
</head>
<body>
<div class="grid-container centered">
<div class="grid-100">
<div class="contained">
<div class="grid-100">
<div class="heading">
<h1>Bring on the AJAX</h1>
<button id="load" onclick="sendAJAX()">Bring it!</button>
</div>
1 Answer
Mary Chadwick
10,683 PointsPlease ... someone remind me that as soon as you post a question, you find the problem when you give it another look! repsonseText is supposed to be responseText! Got it, now!
grahammowat2
6,038 PointsMade the same mistake as you with a slight difference. reponseText instead of responseText Thanks for helping me out!
Robert Richey
Courses Plus Student 16,352 PointsRobert Richey
Courses Plus Student 16,352 PointsEdited for solved