lundi 24 juin 2019

why alert didn't work in a http.onload from an XMLHttpRequest?

const http = new XMLHttpRequest();
const url = 'http://192.168.1.10/';
http.open('get', url, false);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  http.onload = function ()
    {
            if(http.status === 200 || http.status == 0)
            {
                alert("succeed")

            } else {
          alert("failed")

          }
    }
http.send();

why although it didn't get http.status === 200 it didn't alert failed !

image1

image2

Aucun commentaire:

Enregistrer un commentaire