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

171
Visualizações
How do you get form data to submit using AJAX?

I am trying to get a form to submit. I am using HTML, JS, PHP, and AJAX here. Since it will not submit, I assume something is wrong with my insert function, however I cannot figure out what the problem is. Whenever I click "submit" nothing changes. Nothing moves. The information doesnt get added.

<!doctype html>

<html>

<head> 

<script src="./js/jquery-3.6.0.min.js">. 
</head>

<body>

<form onsubmit="return(insertPeople())">

First name: <input type=text id=firstname><br>
Last name: <input type=text id=lastname><br>
Phone number: <input type=text id=telephonenumber><br>
<input type=submit value=submit>

</form>

<div id=showpeople></div>

<script>

function insertPeople(){

val = $("#showpeople").val();

$.get("./week7ajax.php",{"cmd":"create", "firstname,lastname,telephonenumber" : val}, function(data){
$("#showpeople").html(data);
});

return(false);
}

function showpeople(){
$.get("./week7ajax.php",{"cmd":""}, function(data){
$("#showpeople").html(data);
});
return(false);
}

showpeople();

</script>

</body>


</html>
                        
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Give this a shot. I fixed some missing quotations, indented a few lines, and removed some unnecessary code.

<form onsubmit="insertPeople(); return false;">

First name: <input type="text" id="firstname"><br>
Last name: <input type="text" id="lastname"><br>
Phone number: <input type="text" id="telephonenumber"><br>
<input type="submit" value="submit">

</form>

<div id="showpeople"></div>

<script>

function insertPeople() {
    val = $("#showpeople").val();
        $.get("./week7ajax.php",{"cmd":"create", "firstname,lastname,telephonenumber" : val}, function(data){
        $("#showpeople").html(data);
    });
}

function showpeople() {
    $.get("./week7ajax.php",{"cmd":""}, function(data){
        $("#showpeople").html(data);
    });
}

showpeople();

</script>
about 4 years ago · Juan Pablo Isaza Relatório
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