DataTable warning: invalid JSON responce

DataTable warning: invalid JSON responce

yash30yash30 Posts: 1Questions: 1Answers: 0
edited August 2018 in Free community support

Almost spend 8 to 9 hours this warning

I work on localhost
Error message shows in **DataTables warning: table id=manageStudentTable - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1**

public function fetchStudentData($studentId = null)
    {
        if($studentId) {
            $result = $this->model_student1->fetchStudentData($studentId);
        // }
        // else {
        //  $studentData = $this->model_student1->fetchStudentData();
        //  $result = array('data' => array());

            foreach ($studentData as $key => $value) {
                $button = '<!-- Single button -->
                    <div class="btn-group">
                      <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        Action <span class="caret"></span>
                      </button>
                      <ul class="dropdown-menu">
                        <li><a type="button" data-toggle="modal" data-target="#updateStudentModal" onclick="editStudent('.$value['student_id'].')"> <i class="glyphicon glyphicon-edit"></i> Edit</a></li>
                        <li><a type="button" data-toggle="modal" data-target="#removeStudentModal" onclick="removeStudent('.$value['student_id'].')"> <i class="glyphicon glyphicon-trash"></i> Remove</a></li>
                      </ul>
                    </div>';

                $photo = '  <img src="../'.$value['image'].'" alt="Photo" class="img-circle candidate-photo"/>';

                $result['data'][$key] = array(
                    $photo,
                    $value['name'] . ' ' . $value['lname'],
                    $value['age'],
                    $value['contact'],
                    $value['email'],
                    $button
                );
            } // /foreach
            echo json_encode($result);
        }

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    If you follow the instructions in the tech note in the error message, what is being returned from the server? Is it an empty return, or an error message or what?

    Please also link to a page showing the issue or use the debugger to upload a data trace so we can provide some help.

    Allan

This discussion has been closed.