Front-end: Processing data and updating the UI

// This will be called when the request is complete
function processXHR()
{
  // Normally you'd indicate an error to user on xhr.status is not ok
  if (xhr && xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 304))
  {
      updateUI();
  }
  return true;
}

function updateUI()
{
  // Update DOM with xhr.responseText or xhr.responseXML;
}