Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

how to get the CI’s base url in JavaScript

I received a tutorial request from my reader that asked me how to access CI’s base URL inside the JavaScript/external JavaScript files. Editing base URL of the project after each and every deployment is very frustrating and idiotic. There must be a better way to handle this base_url automatically into our js files. Yes, there is a better way, In this tutorial, I will show you most used trick. This trick is applicable to any framework or project.

how to get the CI’s base url in JavaScript

Just add the following code snippet in your master/main layout file, in the head section so that it can be accessible.

What we did – we just declared a JavaScript variable called base_url, that can later be used by external/inline javascript files(variable declaration should be top of all the files).

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments