Getting Error “Form submission canceled because the form is not connected”

Quick answer : append the form to the body. document.body.appendChild(form); Or, if you’re using jQuery as above: $(document.body).append(form); Details : According to the HTML standards, if the form is not associated to the browsing context(document), the form submission will be aborted. HTML SPEC see 4.10.21.3.2 In Chrome 56, this spec was applied. Chrome code diff see @@ -347,9 … Read more

Download File Using JavaScript/jQuery

Use an invisible <iframe>: To force the browser to download a file it would otherwise be capable of rendering (such as HTML or text files), you need the server to set the file’s MIME Type to a nonsensical value, such as application/x-please-download-me or alternatively application/octet-stream, which is used for arbitrary binary data. If you only want to open it in a … Read more

Disabling and enabling a html input button

Using Javascript Disabling a html buttondocument.getElementById(“Button”).disabled = true; Enabling a html buttondocument.getElementById(“Button”).disabled = false; Demo Here Using jQuery All versions of jQuery prior to 1.6 Disabling a html button$(‘#Button’).attr(‘disabled’,’disabled’); Enabling a html button$(‘#Button’).removeAttr(‘disabled’); Demo Here All versions of jQuery after 1.6 Disabling a html button$(‘#Button’).prop(‘disabled’, true); Enabling a html button$(‘#Button’).prop(‘disabled’, false); Demo Here P.S. Updated … Read more

jQuery setTimeout() Function [duplicate]

The problem is that inside the setTimeout() call, this doesn’t refer to the button. You need to set a variable to keep the reference to the button. I’ve created a sample below. See how I use the variable named $this. UPDATE: Now with modern browsers supporting Arrow Functions, you can use them to avoid altering the this context. See updated snippet below.