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

167
Visualizações
¿Cómo PUBLICA datos de formulario html con javascript?

Estoy intentando PUBLICAR datos desde un formulario html usando javascript; sin embargo, al enviarlos, creo que en realidad no se envían datos porque mi alerta no muestra datos.

cuando agregué un cuadro de alerta

 var jsonStr = JSON.stringify(FD); alert(jsonStr);

la salida apareció como "{}"

aquí está mi código completo a continuación si alguien puede detectar mi errora

 <form class="emailentry" " method="post" name="myForm" id="myForm"> <label for ="name">Name: </label><br> <input type ="text"id="name" name="name: " ><br> <label for ="emailad">Email: </label><br> <input type ="email"id="emailad" name="emailad" ><br> <input type= "submit" id="btn" name="submit" class="submitstyle"> </form> <script> window.addEventListener( "load", function () { function sendData() { const XHR = new XMLHttpRequest(); // Bind the FormData object and the form element const FD = new FormData( form ); // Define what happens on successful data submission XHR.addEventListener( "load", function(event) { var jsonStr = JSON.stringify(FD); alert(jsonStr); // should present me the data i entered but it isnt alert("hi"); } ); // Define what happens in case of error XHR.addEventListener( "error", function( event ) { alert( 'Oops! Something went wrong.' ); } ); // Set up our request XHR.open( "POST", "ExampleUrl.ForStackOveerflow/post" ); // The data sent is what the user provided in the form XHR.send( FD ); } // Access the form element... const form = document.getElementById( "myForm" ); // ...and take over its submit event. form.addEventListener( "submit", function ( event ) { event.preventDefault(); sendData(); } ); } ); </script>
about 4 years ago · Juan Pablo Isaza
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