Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

303
Visualizações
why it gives me the mistake that the key 'val' does not exist

I'm having a problem with an ajax request, this is the script:

async function http(data) {
    const objdt = {
        val: data
    }
    const response = await fetch("lib/bot.php", {
        method: "POST",
        hedaers: {"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"},
        body: JSON.stringify({objdt})
    })
    .then(response => response.text())
        .then(data => inschat(data))
    .catch(err => console.log(err));
}

var inschat = (dt) => {
    alert(dt.data);
}

const inpChat = document.querySelector("input[name=chat_input_text]");
inpChat.addEventListener("keypress", (event) => {
    if(event.keyCode === 13 && inpChat.value !== ""){
        let data = inpChat.value;
        http(data);
    }
});

while in php i have this, just to try:

$dt = trim($_POST["val"]);
echo $dt;

but it gives me error Warining Undefined array 'val' can anyone help me thanks i'm bogged down

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda