I'm getting a 404 (Not found) in the console when trying to get data with AJAX in my Slim PHP application. Here's the error message :
http://localhost:8888/Project/mods/public/edit-mod/ajax/get-categories?gameID=1 404 (Not Found)
Here's the route defined in a routes.php file (that is correctly included, all the other routes are working) :
$app->get("/ajax/get-categories/", function() use ($app, $User, $Game, $Mod){
//Fetch data and echo it
});
Finally, here's how I'm calling the AJAX page in the JS script :
$.get("ajax/get-categories", {gameID: gameID}, function(data){
//Do something with data
});
I tried changing the Slim route to "ajax/get-categories/" (without the leading /
) but it didn't change anything, and I also try a bunch of different paths for the AJAX call (in the JS script) but nothing worked, I always get the 404 no matter what.
When I'm calling only ajax/get-categories
in my script, it seems to be appending the current page (ex edit-mod/
) to the route, maybe that's my problem.
Is there a way to match every route that ends with ajax/get-categories
, so that both upload/ajax/get-categories
and edit-mod/ajax/get-categories
will work?
Let me know if you need any more code, I think I've included everything that is relevant to the problem.