AJAX call with CodeIgniter 4 returns 404 errpr

Viewed 22

I have a simple DataTable based page I am building. I want the table to get its data with ajax().

<script>
    $(document).ready(function(){
        $("#tblReport").DataTable({
            dom: 'Bfrtip',
            buttons: [
                'copyHtml5',
                'excelHtml5',
                'pdfHtml5'
            ],
            ajax: {
                url: '/reports/ajaxopenwolist',
                type: 'POST'
            }
        
        
        }
        );
    });
</script>

I have created a method within the controller class. (All other methods in the controller class work fine.) I added a route.

When I load the page, I get a 404 error on the ajax call.

enter image description here

Now, here's the interesting part. If I copy the URL right out of the error message you see in the image and paste that into a browser, I get the JSON data I expected. So, the URL works but not when called within ajax. (And yes, it is all part of the same domain).

Any thoughts on this. I am honestly at a loss with this one.

0 Answers
Related