I am creating a form with ajax submission in my Drupal custom form module.

When I click my submit button, I get the following error:

ajax: ajax.form.ajaxSubmit is not a function.

I am searching some blogs, try something like uninstalling lightbox2 module, color box module, etc. But again the same error is displayed.

How can fix this error?

Note: I installed Lightbox first, but after this error I uninstalled it again.

  • Do you have jquery update or ligthbox installed ? – niksmac May 20 '13 at 3:15
  • I think you haven't included jquery form plugin . ajaxSubmit is not a core jquery function, – niksmac May 20 '13 at 3:50
  • try drupal_add_library('system', 'drupal.form'); – niksmac May 20 '13 at 3:57
  • @NikhilM where I use this code – SKM May 20 '13 at 3:58
  • in the init of the custom module or in the form page. – niksmac May 20 '13 at 4:05

You'll need to include the Drupal ajax drupal_add_library('system', 'drupal.ajax');

  • 1
    where should i inculude this code – SKM May 20 '13 at 3:58
  • not worked after include this code – SKM May 20 '13 at 4:22

For future readers, you may need to include these libraries:

drupal_add_library('system', 'jquery.form');
drupal_add_library('system', 'drupal.ajax');

For example:

function MY_MODULE_my_form_id($form, &$form_state) {

  $form['#attached']['library'][] = array('system', 'jquery.form');
  $form['#attached']['library'][] = array('system', 'drupal.ajax');


Drupal 8

Drupal 8 does not include JS-libraries to pages automaticly. So most probably if you meet this error you need to attach 'drupal.ajax' library to your page (or form). Add something like this to your render array:

$form['#attached']['library'][] = 'drupal.ajax';
  • This question is about Drupal 7 (see "7" tag). So how does this answer the question? – Pierre.Vriens Jul 27 '16 at 9:42
  • 2
    When searching about this issue with D8 we can find this page, it helped me, so it's accurate. – Kgaut Sep 13 '16 at 9:56

Drupal 8

For people coming from Google and looking for a D8 solutions, try:

$form['#attached']['library'][] = 'core/drupal.ajax';
  • What is the correct solution? – Pierre.Vriens May 9 '17 at 7:59

I disabled JavaScript aggregation in the performace config and it fixed my issues with this error in Drupal 8.


In Drupal 8:

   function YOURMODULENAME_page_attachments(array &$attachments) {
      global $base_url;
      $attachments['#attached']['library'][] = 'core/jquery.form';
      $attachments['#attached']['library'][] = 'core/drupal.ajax';
      $attachments['#attached']['library'][] = 'MODUL/login_module';
      $attachments['#attached']['drupalSettings']['LoginModuleBehavior']['base_url'] = $base_url;

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.