Answer the question
In order to leave comments, you need to log in
Why is it displaying a 302 code?
Why if you open the Yandex website, enter something in the search and then write this code in the console and look in the Network tab, it will show the code 302, and then 200?
This opinion is wrong
сначала сервер обрабатыввет данные, если их перебор,
то временно перемещает страницу куда-то и выводит
статус 302, потом её обрабатывает, укорачивает
и возвращает статус 200 и выводит содержимое
getAjax = function (url, success) {
"use strict";
let xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
xhr.open('GET', url);
xhr.onreadystatechange = function () {
if (xhr.readyState > 3 && xhr.status == 200) success(xhr.responseText);
};
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.send();
return xhr;
};
getAjax("https://yandex.ru/search/?text=" + "1".repeat(50000), console.log);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question