First I want to tell you, how my project is structured basically. I have my views and my controllers. Then in public>JS folder I have jQuery placed as well as a plugin called sweealert.
Now I did this, so I'm sending an ajax request to a controller, which then returns data (abouot categories).
Now I have a problem. I have 2 different views, the one has the route /addProduct, there, everything works fine. The other route is for editing products, so those routes are for example /editProduct/1 for the product with the id one. On that view, using that described ajax doesn't work.
Neither the subcategories are switched, nor anything else with jQuery works. The console, tells me why:
https://localhost/editProduct/js/jquery-3.1.1.min.js Failed to load resource: the server responded with a status of 404 (Not Found)
https://localhost/editProduct/js/sweetalert.min.js Failed to load resource: the server responded with a status of 404 (Not Found)
1:4 Uncaught ReferenceError: $ is not defined(…)
So jQuery and the sweetAlert plugin are looked up in the wrong folder, so jQuery is not working, thats why my AJAX success callback isn't working any more as well... Now the question is, WHY? Paths like addProduct work, but paths with something behind (like editProduct/1) doesn't work? And no, there are no typos or anything that could cause the problem, I tried to hardcode the id of the product to edit in the code, so I can call /editProduct and that worked, so it's that id that is added additionally.
Where does this problem come from (why does it search for js files in the wrong directory) and how can I solve it?