Welcome Guest, Not a member yet? Register   Sign In
How to Pass Config Information to JS?
#9

[eluser]Twisted1919[/eluser]
The best solution i found is to have somewhere in your <head> of the website someting like:
Code:
var site = {
base_url : '<?php echo base_url();?>',
site_url : '<?php echo site_url();?>,
...
...
};
Then, after this object, include the rest of your scripts, and in your scripts, call it like :
Code:
site.base_url ;
//EXP:
$(this).attr('src',site.base_url+'images/mine.gif');


Messages In This Thread
How to Pass Config Information to JS? - by El Forum - 09-08-2010, 03:31 PM
How to Pass Config Information to JS? - by El Forum - 09-08-2010, 05:38 PM
How to Pass Config Information to JS? - by El Forum - 09-08-2010, 06:30 PM
How to Pass Config Information to JS? - by El Forum - 09-08-2010, 06:51 PM
How to Pass Config Information to JS? - by El Forum - 09-09-2010, 08:16 AM
How to Pass Config Information to JS? - by El Forum - 09-09-2010, 11:37 AM
How to Pass Config Information to JS? - by El Forum - 09-09-2010, 04:29 PM
How to Pass Config Information to JS? - by El Forum - 09-09-2010, 05:09 PM
How to Pass Config Information to JS? - by El Forum - 09-09-2010, 05:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB