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 trialPai Boony
Courses Plus Student 4,529 Pointsconsole.log not working
I'm using local server on my computer Xampp. I can load XHR "XHR finished loading: GET "http://localhost/AJAX%20Basics/2_Programming%20AJAX/video4/data/employees.json". but the console.log did not show any json. Here is the code
var xhr = new XMLHttpRequest(); xhr.onreadystagechange = function(){ if(xhr.readyState ===4){ var employees = JSON.parse(xhr.responseText); console.log(typeof employees); } }; xhr.open('GET', 'data/employees.json'); xhr.send();
Please help...
3 Answers
Neil McPartlin
14,662 Points6 months on I know, but just for the record...
line 2: change ...stage... -> ...state...
var xhr = new XMLHttpRequest();
xhr.onreadystagechange = function(){ // edit this line to say xhr.onreadystatechange...
if(xhr.readyState ===4){
var employees = JSON.parse(xhr.responseText);
console.log(typeof employees);
}
};
xhr.open('GET', 'data/employees.json');
xhr.send();
Ozgur Parlakkilic
8,399 Pointsyou need to add link to your workspace take a snapshot of it, this doesnt give me enough detail
SUDHA GOPINATH
Courses Plus Student 6,280 Pointsjust create a new workspace.....and just do the same...