Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!