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 trialPitrov Secondary
5,121 PointsShould the examples work, to me they don't.
I think that I copied eveerything but it doesent work, then I try to preview the examples, they dont work either, is it the workspace problem or I need to recheck my code?
5 Answers
Steven Parker
231,269 PointsThere's no way for us to check without seeing your code. But if you're concerned about copying errors, you could download the project files and compare your code against them or use them directly.
If you need to share your code, a great way is to make a snapshot of your workspace and post the link to it here.
Amber Fuller
4,598 PointsI agree with Steven, can you take a snapshot of what you're working on and link your snapshot? I completed the same course a few days ago and my code issues were some minor mistakes that I didn't catch.
Pitrov Secondary
5,121 PointsHere is my code, thanks http://prntscr.com/jdqqqq
Amber Fuller
4,598 PointsOk, I think I have it figured out as comparing to what I have. line 12 should read as follows: document.getElementById('ajax').innerHTML = xhr.responseText;
Also, on line 16 you may want to change it to this: xhr.open('GET', 'sidebar.html');
Pitrov Secondary
5,121 PointsThanks, I copied ur lines in my document, but it still doesn't work. When I refresh my page with google developer tools on, it doesn't say anything, and it doesn't show anything. I really do not know why it not working. This is how it looks like now: http://prntscr.com/jdsl5w
Amber Fuller
4,598 PointsAre you doing the part where it sets an element's display to "none"? If so, here's what I have:
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if(xhr.readyState === 4) {
document.getElementById('ajax').innerHTML = xhr.responseText;
}
};
xhr.open('GET', 'sidebar.html');
function sendAJAX() {
xhr.send();
document.getElementById('load').style.display = "none";
Pitrov Secondary
5,121 PointsI copied all of that and pasted it in the script tags. IT STILL DOESN'T WORK! I do not know what I am doing wrong ( I am using workspace) is there something else I have to do?
Steven Parker
231,269 PointsFYI: The snapshot I was suggesting is very different from a "screenshot". The screenshot is just an image but the snapshot allows the complete workspace environment to be reconstructed and analyzed.
Pitrov Secondary
5,121 PointsI made a snapshot, here it is https://w.trhou.se/zuqlxc2bk5
Pitrov Secondary
5,121 PointsPitrov Secondary
5,121 Pointscan u try tthe examples? here is my code var xhr = new XMLHttpRequest(); xhr.open('GET', 'sidebar.html'); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { document.getElementById('ajax').innerHTML = xhr.responseText; } }; xhr.send();
Steven Parker
231,269 PointsSteven Parker
231,269 PointsI see 3 issues in the snapshot (same as in Amber's posted code):
Pitrov Secondary
5,121 PointsPitrov Secondary
5,121 PointsI Think that I fixed the problems. I think i did the 3th problem wrong, how do I call the "xhr.send"? It still doesn't work
Steven Parker
231,269 PointsSteven Parker
231,269 PointsYou could either call "sendAJAX" or get rid of "sendAJAX" and just call "xhr.send" directly as in the comment you posted to this answer the first time.