1

When the form was doing submit, It's showing this warning message.

The first method:

var btn = document.getElementById('actionBtn');
var form = document.getElementById('actionForm');

form.addEventListener('submit', function(e) {
    e.preventDefault();
    btn.disabled = true;
    form.removeChild(btn);
    document.getElementsByTagName('body')[0].innerHTML = 'start working!';
    form.submit();
});

The second method:

var btn = document.getElementById('actionBtn');

document.getElementById('actionForm').addEventListener('submit', function(e) {
    e.preventDefault();
    btn.disabled = true;
    this.removeChild(btn);
    document.getElementsByTagName('body')[0].innerHTML += 'start working!';
    this.submit();
});

they will be showing this message ("Form submission canceled because the form is not connected").

and this page html:

<form action="./patchPr18mToOesFeeFor189.jsp" method="GET" id="actionForm"> 

    <input type="hidden" name="start" value="start">
    <button id="actionBtn">Let's start</button>

</form>

Why is it so?

Sikandar Sahab
  • 638
  • 3
  • 10
  • 27
J. Hu
  • 53
  • 8
  • You can find a good explanation here. https://stackoverflow.com/questions/42053775/getting-error-form-submission-canceled-because-the-form-is-not-connected Good Luck! – Zeeshan Adil Apr 25 '18 at 05:14
  • 1
    @ZeeshanAdil Thanks! I found the answer! – J. Hu Apr 25 '18 at 07:37

1 Answers1

0

You have to remove the following line:

document.getElementsByTagName('body')[0].innerHTML += 'start working!';
HMR
  • 37,593
  • 24
  • 91
  • 160