tip

Passer base_path dans un script jQuery

webmee - Passer base_path dans un script jQuery

Pour passer base_path(), bien pratique dans Drupal, dans un javascript, disons jQuery, rien de plus simple.

Ce besoin fait sans doute partie d'un développement spécifique, et donc d'un module. Dans ce module ajoutez en invoquant hook_init :

function monmodule_init() {

drupal_add_js( array( 'basepath' => base_path() ), 'setting' );

}

ceci rendra disponible dans votre script

var path = Drupal.settings.basepath;