Thanks to everyone who's commented (especially @jcisio)! Based on all your answers, I was able to come up with thisthe THEMEPATH
global variable which works perfectly:stores the complete path to the theme by using drupal_add_js()
.
drupal_add_js( array( 'themepath' => base_path() . path_to_theme() ), 'setting' );
Which you can then reference in your .js file as
var THEMEPATH; //a global variable
$(function(){
THEMEPATH = Drupal.settings.themepath; //assign the variable
})
//THEMEPATH has to be aassigned globalon variablepage load and not before or else it won't work
So in the end, you simply use it in jQuery as: THEMEPATH + '/code/test-ajax.php'
. I'm surprised Drupal doesn't have this by default.