-
Anonymous
Не загружается анимация, когда я нажимаю кнопку [закрыто]
Сообщение
Anonymous »
Я хочу, чтобы это происходило при нажатии кнопки. Он начнет загружать анимацию до тех пор, пока p.php не получит значения.
HTML CODE
Код Javascript
Код: Выделить всё
document.getElementById('myButton').addEventListener('click', function() {
const inputValue = document.getElementById('myInput').value;
const data = { inputData: inputValue }; // Create an object to send
fetch('p.php', { // Replace with your PHP script path
method: 'POST',
headers: {
'Content-Type': 'application/json', // Specify content type
},
body: JSON.stringify(data), // Convert data to JSON string
})
.then(response => response.text()) // Or .json() if PHP returns JSON
.then(responseText => {
document.getElementById('responseArea').innerHTML = responseText;
})
.catch(error => {
console.error('Error:', error);
});
});
Кто-нибудь может это сделать?
Подробнее здесь:
https://stackoverflow.com/questions/797 ... ick-button
1760330960
Anonymous
Я хочу, чтобы это происходило при нажатии кнопки. Он начнет загружать анимацию до тех пор, пока p.php не получит значения.
HTML CODE
[code]
Send Data
[/code]
Код Javascript
[code]
document.getElementById('myButton').addEventListener('click', function() {
const inputValue = document.getElementById('myInput').value;
const data = { inputData: inputValue }; // Create an object to send
fetch('p.php', { // Replace with your PHP script path
method: 'POST',
headers: {
'Content-Type': 'application/json', // Specify content type
},
body: JSON.stringify(data), // Convert data to JSON string
})
.then(response => response.text()) // Or .json() if PHP returns JSON
.then(responseText => {
document.getElementById('responseArea').innerHTML = responseText;
})
.catch(error => {
console.error('Error:', error);
});
});
[/code]
Кто-нибудь может это сделать?
Подробнее здесь: [url]https://stackoverflow.com/questions/79788444/not-load-animation-when-i-click-button[/url]