Warning: Undefined array key "orderhash" in /home/labreunis/maxkuku.ru/docs/webmaster/index.php on line 177
Список полезных функций
(☞ຈل͜ຈ)☞ Главная  Статьи  Загрузчик Домой


Warning: Undefined variable $name in /home/labreunis/maxkuku.ru/docs/webmaster/index.php on line 209

Warning: Undefined array key "orderhash" in /home/labreunis/maxkuku.ru/docs/webmaster/index.php on line 224

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /home/labreunis/maxkuku.ru/docs/webmaster/index.php on line 224

Warning: Undefined variable $name in /home/labreunis/maxkuku.ru/docs/webmaster/index.php on line 224

Warning: Undefined variable $name in /home/labreunis/maxkuku.ru/docs/webmaster/index.php on line 294
Ok!
Ok!
201
function send(onError, onSuccess, url, method = 'GET', data = null, headers = [], timeout = 60000) {
  let xhr;

  if (window.XMLHttpRequest) {
      // Chrome, Mozilla, Opera, Safari
      xhr = new XMLHttpRequest();
  }  else if (window.ActiveXObject) { 
      // Internet Explorer
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
  }

  xhr.open(method, url, true);


  headers.forEach((header) => {
      xhr.setRequestHeader(header.key, header.value);
  })
  

  xhr.timeout = timeout;

  xhr.onreadystatechange = function () {
      if (xhr.readyState === 4) {
      if(xhr.status >= 400) {
          onError(xhr.statusText)
      } else {
          onSuccess(xhr.responseText)
      }
      }
  }

  xhr.send(data);
}
xhr, request, XMLHttpRequest, JS12090XMLHttpRequest обернутый в функцию