JavaScript AJAX Basics (retiring) Programming AJAX Processing JSON Data

Mohamoud Dandan
Mohamoud Dandan
7,133 Points

Why is my list of employees not populating?

please i need your help i do not know where is my error and here is my code var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ if(xhr.readyState === 4) { var employees = JSON.parse(xhr.responseText); var statusHTML = '<ul class="bulleted">' for (var i=0; i<employees.lenght; i += 1) { if (employees[i].inoffice === true) { statusHTML += '<li class="in">'; }else{ statusHTML +='<li class="out">'; } statusHTML += employess[i].name; statusHTML +='</li>'; } statusHTML += '</ul>'; document.getElementById('employeeList').innerHTML = statusHTML; } };

xhr.open('GET', 'data/employees.json'); xhr.send();

Hi Mahamoud - Happy to help, but first could you display your code using the Markdown Cheatsheet (see link below) so that's formatted in a way for people to easily read?

Mohamoud Dandan
Mohamoud Dandan
7,133 Points

thank you guys I fixed the issue thank you all !!