Welcome Guest, Not a member yet? Register   Sign In
ajax request 404 error
#1

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({
            dom: 'Bfrtip',
            buttons: [
                'copyHtml5',
                'excelHtml5',
                'pdfHtml5'
            ],
            ajax: {
                url: '/reports/ajaxopenwolist',
                type: 'POST'
            }
       
       
        }
        );

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?
Reply
#2

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"
Reply
#3

(This post was last modified: 09-22-2022, 02:10 AM by superior.)

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/incom...al-options
> url_to() - https://codeigniter.com/user_guide/helpe...tml#url_to
Reply




Theme © iAndrew 2016 - Forum software by © MyBB