Skip to main content
2 of 3
added 86 characters in body
enchance
  • 2.1k
  • 5
  • 39
  • 50

Thanks to everyone who's commented! Based on all your answers I was able to come up with this which works perfectly:

drupal_add_js( array( 'themepath' => base_path() . path_to_theme() ), 'setting' );

Which you can then reference in your .js file as

var THEMEPATH; //global variable
$(function(){
    THEMEPATH = Drupal.settings.themepath;
})

//THEMEPATH has to be a global variable or else it won't work

So in the end, you simply use it in jQuery as: THEMEPATH + '/code/test-ajax.php'

enchance
  • 2.1k
  • 5
  • 39
  • 50