JavaScript AJAX Basics (retiring) Programming AJAX Processing JSON Data

looks like the li is only closed for the else clause

 if(xhr.readyState === 4) { 
convert string to js, store in var employees
    var employees = JSON.parse(xhr.responseText);
generate ul w/html, store in var statusHTML
    var statusHTML = "< ul class='bulleted' >";
for loop, employee list stored in employee
    for (var i=0; i < employees.length; i += 1) {
condition
      if (employees[i].inoffice === true) {
generate in class in
        statusHTML += '< li class="in" >';
generate out class
      } else {
        statusHTML += '< li class="out" >';
        statusHTML += '< /li >';
      }
    statusHTML += '' ; 
    document.getElementById('employeeList').innerHTML =
    statusHTML;
  }
};

omg..it worked!!! I finally learned how to post code to the forum :D

1 Answer

Steven Parker
Steven Parker
182,024 Points

That's not how it's done in the video. The video shows the name and the closing tag being added AFTER the else block, so every employee will get both.

oh yea, ty