$( document ).ready(function() {
//удаляем тильдовскую отправку формы
$( "#form371121162 button[type='submit']" ).attr('id', 'submit-btn');
$( "#form371121162 button[type='submit']" ).removeAttr('type');
//добавляем ajax по клику на кнопку
$( "#form371121162 #submit-btn" ).click(function(e) {
console.dir(e);
var msg = new FormData($("#form371121162")[0]);
$.ajax({
data: msg,
method: "POST",
url: '/api.php',
});
});
});
for (var i = 0; i < 250; i++) {
var response = await $.ajax('api/page=' + i);
console.log('Получены данные:');
console.dir(response);
// Здесь впиши условие остановки:
if (условие) {
i = 250; // Увеличиваем счетчик до 250, это приведет к остановке цикла
}
}
// Здесь пиши дальше свой код
var original = {
open: XMLHttpRequest.prototype.open,
send: XMLHttpRequest.prototype.send
};
XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
console.log(url);
return original.open.call(this, method, url, async, user, password);
};
XMLHttpRequest.prototype.send = function (data) {
console.log(data);
return original.send.call(this, data);
};
document.querySelector('#search').dispatchEvent(new Event('input'));
document.querySelector('#search').dispatchEvent(new Event('change'));