how to find out if XMLHttpRequest.send() worked

Something like the following code should do the job:

    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState === 4) {
        var response = JSON.parse(xmlhttp.responseText);
          if (xmlhttp.status === 200) {
             console.log('successful');
          } else {
             console.log('failed');
          }
      }
    }

Leave a Comment