![]() |
ajax request 404 error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: ajax request 404 error (/showthread.php?tid=83111) |
ajax request 404 error - bazianm - 09-21-2022 I am working on a simple DataTables page. The DataTable will get the data with an Ajax Call. My DataTables setup (javaScript) is below: Code: $("#tblReport").DataTable({ I have a controller class called Reports.php and all my other methods work fine. When I load the datatables, I get a 404 error. However, when I type the same address in my browser, I get the JSON data I expected. I have added the method to the Routes.php file as well. Does anyone have any ideas? RE: ajax request 404 error - JustJohnQ - 09-21-2022 It looks like you're using server-side processing, yet you don't process the data from your ajax call. Replace it with the following: PHP Code: "sAjaxSource": "/reports/ajaxopenwolist", RE: ajax request 404 error - superior - 09-22-2022 See: https://codeigniter.com/user_guide/general/ajax.html On your ajax part you would add headers to support this. edit: It also depends on what the URL in your routes is accepting, if for example you use the get() method. Personally i would use (and i'm using this) the url_to() for this part. > routes - https://codeigniter.com/user_guide/incoming/routing.html#global-options > url_to() - https://codeigniter.com/user_guide/helpers/url_helper.html#url_to |