I'm having trouble with using correct path names in local Javascript with a Codeigniter backend.
My Codeigniter file directory looks like this
-user_data
-application
-system
-assets
In my JS I define the path I want to use which is user_data like so:
var user_file_location = 'user_data';
I have a function (in my local JS) that preloads images based on a given url:
loader.addImage(image_url);
Now when I try to load an image from the directory user_data like so:
loader.addImage(user_file_location + 'grass.png')
I get the following error in the browser console:
GET http://localhost/index.php/userdata/grass.png 404 (Not Found)
So, the url the function loader.addImage() is trying to get the image from is incorrect.
My question
What is a good way to achieve what I'm trying to do? Should I build an ajax function that asks Codeigniter the base_url() and somehow use that in my JS?
Please help, I'm completely lost.
loader.addImagecode as well. Most likely the error is there.