Welcome Guest, Not a member yet? Register   Sign In
How to use base_url() in js file
#10

[eluser]obay[/eluser]
[quote author="Đaяк Đaηтє" date="1264843123"]Is no possible to use base_url() directly in js file... maybe this can be helpful:

Code:
//myjsfile.js.php
header ("content-type: text/javascript; charset: UTF-8");
var base_url='<?php echo base_url() ?>';
....

But i´m not completly sure....[/quote]

You can't do that because the .js.php is saved outside the application/ folder wihle the base_url() is inside the application/ folder hence it can't find the base_url() helper.

I tried moving the .js.php file inside the application/views/ folder, but it still doesn't work. Trying to access the .js.php in there gives "Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server."

Any ideas, anyone?


Messages In This Thread
How to use base_url() in js file - by El Forum - 01-27-2010, 03:40 PM
How to use base_url() in js file - by El Forum - 01-27-2010, 03:59 PM
How to use base_url() in js file - by El Forum - 01-27-2010, 04:12 PM
How to use base_url() in js file - by El Forum - 01-27-2010, 04:15 PM
How to use base_url() in js file - by El Forum - 01-27-2010, 04:39 PM
How to use base_url() in js file - by El Forum - 01-27-2010, 04:46 PM
How to use base_url() in js file - by El Forum - 01-27-2010, 05:11 PM
How to use base_url() in js file - by El Forum - 01-27-2010, 05:15 PM
How to use base_url() in js file - by El Forum - 01-30-2010, 02:18 AM
How to use base_url() in js file - by El Forum - 02-02-2012, 06:44 AM
How to use base_url() in js file - by El Forum - 02-02-2012, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB