function sendPostWithData(url, data) { // Создаем новый элемент формы const form = document.createElement('form'); form.setAttribute('method', 'post'); form.setAttribute('action', url); // Добавляем скрытые поля для каждого параметра данных Object.keys(data).forEach(function(key) { const input = document.createElement('input'); input.setAttribute('type', 'hidden'); input.setAttribute('name', key); input.setAttribute('value', data[key]); form.appendChild(input); }); // Добавляем форму на страницу (в конец body) document.body.appendChild(form); // Отправляем форму form.submit(); // Удаляем форму после отправки (не обязательно, но можно для очистки) document.body.removeChild(form); }