Skip to content

Instantly share code, notes, and snippets.

@kalabro
Last active December 29, 2015 11:49
Show Gist options
  • Save kalabro/7666574 to your computer and use it in GitHub Desktop.
Save kalabro/7666574 to your computer and use it in GitHub Desktop.
Lightweight AJAX Drupal entry point. There is also https://drupal.org/project/js module for this purpose.
<?php
/**
* @file
* Custom ajax handler for custom_fast_ajax module.
*/
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
// Include utils.
require_once DRUPAL_ROOT . '/includes/common.inc';
// Light bootstrap.
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
// Our module.
require_once drupal_get_path('module', 'custom_fast_ajax') . '/custom_fast_ajax.module';
$mode = check_plain($_GET['mode']);
$results = array('mode' => $mode, 'data' => array());
if ($mode == 'some_check_here') {
_custom_fast_ajax_fast_ajax($results);
}
drupal_json_output($results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment