Differences in Chrome Queries vs. Firefox XHR

While playing with XHR requests, I found an interesting thing in creating XHR requests from two main browsers - Google Chrome and Mozilla Firefox. The request was a simple HEADrequest www.google.ba:

var xhr = new XMLHttpRequest();
xhr.open('HEAD' , 'www.google.ba', true);

xhr.onreadystatechange = function (aEvt){
  if (xhr.readyState == 4) {
    if (xhr.status >= 200 && xhr.status < 304) {
      console.log('Connected');
    } else {
      console.log('No net');
    }
  }
};

xhr.send();

After trying to make an XHR request, while there was no connection, I would get readyState 4 and status 0 in both browsers. After I reconnected, the XHR request from both browsers was successful.

, , , Chrome readyState 4 0 9 , Firefox - . 13 , . 0 Firefox 13 . -, Firefox?

Chrome:

enter image description here

Firefox:

enter image description here

EDIT:

, Firefox , work offline , , Chrome. , Chrome?

+4

Source: https://habr.com/ru/post/1598872/


All Articles