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.

CommentFileSizeAuthor
#3 ajax.js_.patch659 bytesleanazulyoro
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cerup’s picture

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.

cerup’s picture

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

Apologies - marking this for the dev version.

leanazulyoro’s picture

Status: Active » Needs review
FileSize
659 bytes

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

YK85’s picture

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

MustangGB’s picture

Subscribing

Patch is dodgy ;D

crutch’s picture

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

symptom: editing a node and clicking submit button

boblesurfeur’s picture

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

dhon’s picture

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;
};
sunshinee’s picture

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.

YK85’s picture

subscribing

crutch’s picture

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.

koushal’s picture

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

brendoncrawford’s picture

Is there a working patch for this?

brendoncrawford’s picture

Status: Needs review » Postponed (maintainer needs more info)
soulston’s picture

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

jrstmartin’s picture

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.

brendoncrawford’s picture

Status: Postponed (maintainer needs more info) » Fixed

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

nagrgk’s picture

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

karai’s picture

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

Status: Fixed » Closed (fixed)

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

caspercash’s picture

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

aze2010’s picture

subscribing