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 trialWyatt Gould
9,362 PointsThe events .readyState and .onreadystatechange are not working in my Parsing JSON Data workspace. Any suggestions why?
The events are not turning orange in the code as they should be..
Wyatt Gould
9,362 Pointsvar xhr = new XMLHttpRequest();
xhr.onreadystatechange = function ();
if(xhr.readyState === 4) {
var employees = JSON.parse(xhr.responseText);
}
};
xhr.open('GET', 'data/employee.json');
xhr.send();
I don't know if this will help. It doesn't seem to be the code. It seems to be a problem with workspace not recognizing events. This code works in Adobe Edge.
Jonathan Archer
9,786 PointsNot sure about the colors (they may have updated the color scheme in Workspace since they did the video—I don't get orange for either of those), but you were missing the curly braces on the xhr.onreadystatechange anonymous function. Maybe that will fix it.
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if(xhr.readyState === 4) {
var employees = JSON.parse(xhr.responseText);
}
};
xhr.open('GET', 'data/employee.json');
xhr.send();
1 Answer
Wyatt Gould
9,362 PointsHuh... It still doesn't work. I also would wonder why they would decide to change the color scheme of the code?? So I decided to move on to the next stage and now the next stage doesn't have any of the files for the what they are working on in workspace. The whole AJAX track has been riddled with glitches for me... I may have to just move on to a whole other section until they fix it. Thanks for the help!
Jonathan Archer
9,786 PointsWhat lesson are you on specifically? I can copy my exact code here if you let me know.
Nicholas Olsen
Front End Web Development Techdegree Student 19,342 PointsNicholas Olsen
Front End Web Development Techdegree Student 19,342 PointsCan you post your code for us? See the link "Markdown Cheatsheet" under the reply textarea to see how.