Download & Extend

ajax.module: An unknown error has occurred - when someone clicks 'submit' twice or more

Project:Ajax
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

The following error happens "ajax.module: An unknown error has occurred." when a user clicks 'submit' more than once (which happens quite often).

This is often accompanied by "This content has been modified by another user." because it things someone else is saving the form as it's being edited.

The submit button needs to be deactivated when the user clicks submit or else this will happen every time. I believe this is also the cause of various similar error with this module.

Comments

#1

Priority:normal» critical

I'm marking this as critical considering the number of similar issues and because this error is a deal breaker for anyone that wants to use this module in a production environment. If you feel it's not crticial, feel free to downgrade it.

#2

Version:6.x-1.9» 6.x-1.x-dev

Apologies - marking this for the dev version.

#3

Status:active» needs review

I've solved this by disabling the submit button when it's first click and enabling it back again when it has finished the request. i did this in the ajax.js file. I'm attaching a patch, please review and make sure it works.

regards

AttachmentSize
ajax.js_.patch 659 bytes

#4

EDIT: removed as my comment was not related to this patch. Thanks

#5

Subscribing

Patch is dodgy ;D

#6

getting today after recent core and module updates - ajax.module: An unknown error has occurred.

symptom: editing a node and clicking submit button

#7

I have the same issue..

I dynamically load a View with an argument. In this view I use Ajax pager.

When I go to the page 2 (or 3) and submit a Comment it triggers 2 or 3 times the submit form (number of trigger : nbr_page-1)

The first post works but then I have this error and it reload all my views...

Kind regards

#8

Found a solution, using the patch on #3 comment:

I've edited ajax.js located in ajax module folder,

find Drupal.Ajax.go function approx. on line 83 and replace the whole function:

this is the original:

Drupal.Ajax.go = function(formObj, submitter) {
  var submitterVal, submitterName, extraData;
  Drupal.Ajax.invoke('submit', {submitter:submitter});
  submitterVal = submitter.val();
  submitterName = submitter.attr('name');
  submitter.val(Drupal.t('Loading...'));
  extraData = {};
  extraData[submitterName] = submitterVal;
  extraData['drupal_ajax'] = '1';
  formObj.a_ajaxSubmit({   
    extraData : extraData,
    beforeSubmit : function(data) {
      data[data.length] = {
        name : submitterName,
        value : submitterVal
      };
      data[data.length] = {
        name : 'drupal_ajax',
        value : '1'
      };
      return true;
    },
    dataType : 'json',
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      window.alert(Drupal.t('ajax.module: An unknown error has occurred.'));
      if (window.console) {
        console.log('error', arguments);
      }
      return true;
    },
    success: function(data){
      submitter.val(submitterVal);
      Drupal.Ajax.response(submitter, formObj, data);
      return true;
    }
  });
  return false;
};

Replace with this one:

Drupal.Ajax.go = function(formObj, submitter) {
  var submitterVal, submitterName, extraData;
  Drupal.Ajax.invoke('submit', {submitter:submitter});
  submitterVal = submitter.val();
  submitterName = submitter.attr('name');
  submitter.val(Drupal.t('Loading...'));
  extraData = {};
  extraData[submitterName] = submitterVal;
  extraData['drupal_ajax'] = '1';
  formObj.a_ajaxSubmit({   
    extraData : extraData,
    beforeSubmit : function(data) {
      data[data.length] = {
        name : submitterName,
        value : submitterVal
      };
      data[data.length] = {
        name : 'drupal_ajax',
        value : '1'
      };
      submitter.attr('disabled', 'disabled');
      return true;
    },
    dataType : 'json',
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      window.alert(Drupal.t('ajax.module: An unknown error has occurred.'));
      if (window.console) {
        console.log('error', arguments);
      }
      return true;
    },
    success: function(data){
      submitter.val(submitterVal);
      Drupal.Ajax.response(submitter, formObj, data);
      submitter.removeAttr('disabled');
      return true;
    }
  });
  return false;
};

#9

having the same problem, but cannot be sure it the result of clicking submit twice. is this related to http://drupal.org/node/786502? I'll test the solution in #8 and report back.

#10

subscribing

#11

encountering similar issue as this one: http://drupal.org/node/1069324

----symptom

little white box on login in IE
FF6 gives AJAX error and doesn't allow login at all

Have Ajax module installed and only AJAX and AJAX UI is checked/used.

----fix
login with IE
Disabled those 2 items and everything works fine again.
Unable to use AJAX module at this point.

#12

hi,

my login - register block is working fine, but when I am trying to add user through admin panel and fill the form when I click on signup, I am getting Ajax.module: An unknown error occurred.
please help

#13

Is there a working patch for this?

#14

Status:needs review» postponed (maintainer needs more info)

#15

I'm getting this behaviour on D6 when submitting a webform form that has a mandatory email address field. This seems to be line 106 in ajax.js.

Maybe it's related to this issue - http://drupal.org/node/786502

dataType : 'json',
    error: function (XMLHttpRequest, textStatus, errorThrown) {
      window.alert(Drupal.t('ajax.module: An unknown error has occurred.'));
      if (window.console) {
        console.log('error', arguments);
      }
      return true;
    },

Drupal 6.22
Ajax 6.x-1.15

#16

I always get that message on a node save, but the node always saves correctly, so I just removed the error function for it :D. I have no idea what the problem is :/. My nodes have a lot of processing that takes place. It takes maybe 10 - 15 seconds for a node to save on my site. I'm on the latest D6 (Pressflow) with Ajax Module 6.x-1.x-dev, 2011-Apr-08. I run Open Publish and use the Rubik admin theme.

#17

Status:postponed (maintainer needs more info)» fixed

Fixed thanks to @cluke009's contribution at https://github.com/brendoncrawford/drupal-ajax/pull/2

#18

Guys , i understood where exactly this error is loading from. The ajax error due to parsing error. The function of form_set_ error is working with jquery 1.3 ver .Its doesnot support laest versions .So, W e need o add json_decode function in inc.php which will solve ajax login/register error. If you have more questions , reply on same

#19

nagrgk,
Can you explain exactly what I have to do to add json_decode function inside inc.php?

I have got this problem and I want to solve it!

Thank you

#20

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#21

nagrgk,
can you elaborate and post here on how to solve this one?
Thanks!

#22

subscribing

nobody click here