JavaScript AJAX Basics (retiring) Programming AJAX Processing JSON Data

1 Answer

NaN stands for Not a Number. Maybe there's a problem with arithmetic or numbers in your code.

The only way I can help is by looking at your code. Please provide your code.

OLUBUKOLA OGUNSOLA
OLUBUKOLA OGUNSOLA
Front End Web Development Techdegree Graduate 14,072 Points

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.length;i++){ if(employees[i].inoffice === true) { statusHTML += '<li class= "in">'; } else { statusHTML += '<li class= "out">'; }

  statusHTML += employees[i].name;
  statusHTML =+ "</li>";
}
  statusHTML += '</ul>';
document.getElementById("employeeList").innerHTML = statusHTML;

} };

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