I'm having a problem where my site users are submitting a form before the files they are uploading into filefield are finished, this is causing an ajax error to pop up along the lines of "an ajax HTTP request terminated abnormally".

To stop this mistake from happening is there a way to hide the "Submit"/"Save" button until file has finished uploading?


Havent tried this, but you might be able to use jquery's global ajax event handlers, to hide the submit button, in particular the .ajaxStart() and .ajaxComplete() handlers. Something like the following, added in a .js file in a custom module (not tested):

(function ($) {
  Drupal.behaviors.YOURMODULE = {
   attach: function (context) {

You'd have to edit that to work the way you need it to, save it in a js file, and add it to the node edit form (or any other form you need it for).

Aside from that, the "ajax HTTP request terminated abnormally" errors occur in D7 whenever a http request is made before an ajax request has completed. In my opinion this is undesirable behaviour. It's been discussed here, for example, and the prevent js alerts module suppresses such errors across your site.

  • I think you should only use Drupal.behaviors.*.attach, if you then also use the "context" variable in your selector. In this case, you are attaching a behavior to the document root, so you do not need Drupal.behaviors.
    – donquixote
    Jan 11 '18 at 4:16

try this....

$('#edit-submit').bind('click',function() {
    url: Drupal.settings.life_style.secure_base_url+'path_to_form',
    data: data,
    success: function(result) {
         dataType: "html"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.