Datatable cannot fetch from AJAX file

Datatable cannot fetch from AJAX file

naokinaoki Posts: 2Questions: 1Answers: 0
edited November 2015 in Free community support

This is my ajax code:

<?php
include "db.php";

class classDetails {

public function classDetails(){
    // create sql query


 $viewClass = "SELECT class.id, class.day, class.start_time, class.end_time, subject.subject_name, tutor.tutor_id, tutor.tutor_name AS t_name, classroom.room
 FROM class, subject, tutor, classroom
 WHERE class.subject_id = subject.id
 AND class.tutor_id = tutor.id
 AND class.classroom_id = classroom.id";

 return $this->query($viewClass);            
}

}

and this is my datatable code:

<script type="text/javascript">
    $(document).ready(function() {
        //$.fn.dataTable.TableTools.defaults.aButtons = [ "csv" ];
        $('.datatable').DataTable({
            destroy: true,
            responsive: true,
            serverSide: true,
            processing: true,       
            lengthMenu: [ [10, 25, 50, -1], [10, 25, 50, "All"] ],
            ajax: {
                url: "http://localhost/FYP/ajax.php/classDetails/",                
                type: "POST",
                data: { method: "get" } //data to be sent
                }, 
                dom: 'T<"clear">lfrtip',
                tableTools: {
                    "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf"
                },   
                columns : [
                    {
                        data: "id",
                        render: function(data, row) {
                            return '<a href="http://localhost/FYP/viewClass' + row.id + '/">' + data + '</a>';                    
                        }                
                    },
</script>

I am unable to call it out and I keep getting error tn1

Answers

This discussion has been closed.