How to get base base path in jquery via drupal

    To get base path in jquery from drupal is a simple process you can do this in following way
    //In a custom module create a hook_init()
    function testcustom_init() {
    //this will add base path to drupal object
    drupal_add_js( array( 'basepath' => base_path() ), 'setting' );

    To access base path in jquery you can simply use:
      var path = Drupal.settings.basepath;
    Average: 5 (1 vote)