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

231
Visualizações
How to summit the form and delete html button in the 1 click using javascript

In my code, I use javascript to send data to python(flask) and delete the button when it is successful. the code of the button is given below

The result is that it sends the data to python and the backend function on python is work but the button is not be deleted. I write alert(p) in the success:function because I want to know whether the function is used or not and it alerts!!. I am really new to HTML and javascript. Please someone explain how it works and tell me how to solve it!

$(document).on('submit', '#todo-form2', function(e) {
  console.log('hello');
  e.preventDefault();
  $.ajax({
    type: 'POST',
    url: '/delete',
    data: {
      todo: $("#todo").val()
    },
    success: function() {
      var p = $("#todo").val()
      alert(p);
      var elem = document.getElementByName(p);
      elem.parentNode.removeChild(elem);
    }
  })
});
<form method="post" id="todo-form">
  <button class="primary" name="560510531" id="todo" type="submit" value=560510531> 
    Accept 
    </button>
</form>
<form method="post" id="todo-form2">
  <button class="primary ghost" name="560510531" id="todo" type="submit" value=560510531> 
    Deny 
    </button>
</form>
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