1
In the link below, I managed to send a parameter via fetch by body, but I need to send more than one, for example, values of a form.
I need an example, using POST to send through the body, for example: id: 1234, name: Test, type: payment etc, something like that.
Thanks, help.
I’m not able to send a POST to PHP by Javascript fetch
fnConsultarDadosPost = () => {
const nome = document.querySelector('#nome').value
fetch('dados.php', {
method: 'POST',
body: nome,
headers: {
'Content-Type': 'plain/text'
}
})
.then(res => res.text())
.then(res => fnExibirResultado(res))
}
fnExibirResultado = (dados) => {
document.querySelector('#mensagem').innerHTML = dados
}
Sorry I would like to add that I am trying to move to a PHP page. Getting through the data, how do I get it in PHP. Thank you.
– gbsilva
edit your question and put that information there instead of adding a comment
– Ricardo Pontual