Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadPhones() {
- var xhr = new XMLHttpRequest();
- xhr.open('POST', 'some.php', true);
- xhr.send();
- xhr.onreadystatechange = function() {
- console.log(xhr);
- if (xhr.readyState != 4) return;
- button.innerHTML = 'Готово!';
- console.log(xhr);
- if (xhr.status != 200) {
- // обработать ошибку
- alert(xhr.status + ': ' + xhr.statusText);
- } else {
- // вывести результат
- console.log(xhr.responseText);
- }
- }
- button.innerHTML = 'Загружаю...';
- button.disabled = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement