Invalid JSON response

Invalid JSON response

andrey123andrey123 Posts: 2Questions: 0Answers: 0
edited December 2016 in Free community support

Hello my friends.
I'm use server-side processing with ajax request following the example manual. I'm use for work Zend Framework 1.
My script:
$(document).ready(function() {
var table = $('#dataTable').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "",
"dataSrc" : ""

} );
} );

My zend action :

public function browseAction() {
$table = 'exam_result';
$primaryKey = 'id';
$columns = array(
array('db' => 'exam_id', 'dt' => 1),
array('db' => 'date', 'dt' => 0),
array('db' => 'mark', 'dt' => 2),
);
$sql_details = array(
'user' => 'root',
'pass' => '',
'db' => 'quiz',
'host' => 'localhost'
);
$json = json_encode(
Application_Model_Ajax::simple($_POST, $sql_details, $table, $primaryKey, $columns)
);
echo $json;
$id = $this->_getParam('id');
$userMapper = new Application_Model_UserMapper();
$user = $userMapper->findObject($id);
$this->view->user = $user;

}

And in the end I get (see image)
" Invalid JSON response".

How to ask for a plugin to put everything in place? (I apologize for my English)

json.JPG 247.1K

Replies

  • andrey123andrey123 Posts: 2Questions: 0Answers: 0

    Thank's it work !
    I add

    $this->getHelper('json')->sendJson($json);
    and edit

    Application_Model_Ajax::simple($_GET, $sql_details, $table, $primaryKey, $columns)
    );

This discussion has been closed.