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

[eluser]slowgary[/eluser]
Remember also, your browser doesn't necessarily care what your file extensions are. So you could potentially do something like this in your pages:
Code:
// point your script to a CodeIgniter Controller
< script type='text/javascript' src='/myjavascript' >< /script >
Then, in that controller:
Code:
class Myjavascript extends Controller
{
     function _remap()
     {
          $this->load->view('myjavascript');
     }
}
Then in the "myjavascript" view:
Code:
var base_url = "<?php echo $base_url; ?>";

As long as the contents of your view are valid JavaScript, your browser will still be happy, and you can set your JavaScript variables using PHP variables, which means they'll always be consistent.

I hope this helps.


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