[Solved] Setting url in a .js file |
I have set my url in a js file
Code: assets And I have a controller called Filemanager.php Code: application When I try click on my button which trys to launch modal. It gives the wrong location and a 404 error The url out puts Code: http://localhost/project-1/question/filemanager How ever should only produce Code: http://localhost/project-1/filemanager assets > jquery > common.js Code: $(document).ready(function() { Routes.php Code: $route['filemanager'] = 'filemanager/index'; Any idea in how to make sure it gets the right url I cannot use base_url in a js file.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
As a work around I have a view that is use in every pages.
The view is to set default styles and Javascript for the site. This include a JavaScript variable for the site URL PHP Code: <script type="text/javascript"> Then use the variable to make the URL Code: $(document).ready(function() { I hope this helps. A good decision is based on knowledge and not on numbers. - Plato
(11-01-2016, 10:45 PM)salain Wrote: As a work around I have a view that is use in every pages. I can access the url in browser but when use ajax says network error even though url is correct now.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
I never had any issues but I have no route setup for url I use with ajax.
Maybe ajax by pass the route, but that being said it should work as the index method is default. Sorry, I don't know what could be the problem. A good decision is based on knowledge and not on numbers. - Plato
PHP Code: <script type="text/javascript"> What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-02-2016, 03:07 AM)InsiteFX Wrote: Your one worked plus on common.js miss spelt also filemanager so both now are fixed.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
(11-02-2016, 03:20 AM)wolfgang1983 Wrote:(11-02-2016, 03:07 AM)InsiteFX Wrote: You can also do the same using site_url if you need the index.php What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |