Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing an ajax validation for duplicate check on link field in node form. When the link field is edited, an ajax call is triggered as programmed (using form api #ajax default blur event), it takes a while for the ajax response to reach browser, in the meantime the form gets almost ready to submit by user. Doing an early form submit (i.e before the receipt of ajax response) Drupal ajax API throws below error message in JavaScript alert box,

An AJAX HTTP request terminated unexpectedly
Debug information follows.
Path: /system/ajax
Status text:
Answer Text:
Ready State: 4

I have noticed this issue in a few contrib modules as well. I think the fix is to prevent submitting the form to server until the ajax request completes. Wondering to know if there is any way to set client side callback function in form api that I can use to stop form submit.

share|improve this question
up vote 1 down vote accepted

This might help you.

Drupal.behaviors.merchant = {
  attach: function(context, settings) {
      .ajaxStart( function() {
          jQuery(this).submit(function() {
            return false;
       .ajaxStop( function() {
          jQuery(this).submit(function() {
            return true;
share|improve this answer
Thank you. This is what I was expecting for. – Sivaji Feb 12 '13 at 10:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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