JavaScript API

This guide describes the APIs in Drupal dealing with JavaScript, AJAX, and AHAH.

    Adding JavaScript to your theme or module

    The Drupal API function drupal_add_js() lets you add a JavaScript file, setting or inline code to the page and it takes 5 parameters (see

    JavaScript API overview

    This page is a description of how JavaScript is implemented in Drupal 7, including an in-depth look at the drupal.js file.

    Introducing jQuery

    jQuery is a cross-browser JavaScript library, which means it provides some pre-defined functions to make your life easier.

    Managing JavaScript in Drupal 7

    Drupal 7 has introduced several new techniques that allow you far greater flexibility and control in the scripts you can have on your Drupal

    Debugging JavaScript

    If you don't have an IDE that can debug JavaScript for you, then one alternative is the Firefox add-on called Firebug.

    Ajax Forms in Drupal 7

    How to use ajax in your Drupal forms without writing your own custom Javascript.

    Ajax in Drupal using jQuery

    Ajax is a type of functionality that enables your pages to retrieve information from a resource on the server without the need to reload.

    Multiple different versions of jQuery co-existing

    Adding a different version of jQuery for your codebase with its own identifier.

    Creating custom Drupal.ajax object 'on the fly' and attach it to any DOM element on the page (div, td, span etc.)

    Add AJAX capability to a new DOM element

    Add More Button for Text field /file field using AHAH with drupal 7 form API

    Example Code snippet to create ADD MORE BUTTON with drupal 7 form API

    Simple Drupal AJAX load with jQuery and delivery callback

    Simple Drupal AJAX load with jQuery and delivery callback

    Guide maintainers