 <p>Since you're using WordPress, the propper way of doing this is to send a JavaScript variable with <code>wp_localize_script</code> in <code>functions.php</code>:</p> <pre><code>add_action('wp_enqueue_scripts', 'my_frontend_data'); function my_frontend_data() { global $current_user; wp_localize_script('data', 'Data', array( 'userMeta' =&gt; get_user_meta($current_user-&gt;ID, '_fbpost_status', true), 'templateUrl' =&gt; get_template_directory_uri() )); } </code></pre> <p>The above will add a JavaScript <code>Data</code> variable that's accessible in all your pages. Then you can use it in the front-end like so:</p> <pre><code>var ajaxUrl = Data.templateUrl +'/includes/ajaxswitch/'; $('#1').iphoneSwitch(Data.userMeta, function() { $('#ajax').load(ajaxUrl +'on.php'); }, function() { $('#ajax').load(ajaxUrl +'off.php'); }, { switch_on_container_path: Data.templateUrl +'iphone_switch_container_off.png'; }); </code></pre>