JSON data from server could not be parsed. This is caused by a JSON formatting error.
JSON data from server could not be parsed. This is caused by a JSON formatting error.
RobsonBarreto
Posts: 0Questions: 0Answers: 0
Hello guys, i am confronting a big problem ! I use jsp and i am trying to list data of my database in DataTable, but the following message is displayed:JSON data from server could not be parsed. This is caused by a JSON formatting error ! below my HTML and JSON:
[code] <%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
SGL 1.0 - Brasil Iphone
@import url("TelaInicial.css");
div#corpo{margin: 0 auto; padding: 0; width: 960px; background:silver; height: 400px;}
$(document).ready(function() {
$('#tabela1').dataTable( {
"bPaginate": true,
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "server_processing.php"
} );
} );
Cliente
Funcionário
Produto
Serviço
Código
Nome
Endereço
Cidade
Complementp
Cep
Rg
Cpf
Uf
Telefone
Celular
Email
[/code]
[code]<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array ('codigo', 'nome', 'endereco', 'cidade', 'complemento', 'cep', 'rg', 'cpf', 'uf', 'telefone1', 'telefone2', 'email');
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "codigo";
/* DB table to use */
$sTable = "id";
/* Database connection information */
$gaSql['user'] = "robson";
$gaSql['password'] = "1234";
$gaSql['db'] = "tcc";
$gaSql['server'] = "localhost";
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* Local functions
*/
function fatal_error ( $sErrorMessage = '' )
{
header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
die( $sErrorMessage );
}
/*
* MySQL connection
*/
if ( ! $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) )
{
fatal_error( 'Could not open connection to server' );
}
if ( ! mysql_select_db( $gaSql['db'], $gaSql['link'] ) )
{
fatal_error( 'Could not select database ' );
}
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
intval( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i[/code]
[code] <%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
SGL 1.0 - Brasil Iphone
@import url("TelaInicial.css");
div#corpo{margin: 0 auto; padding: 0; width: 960px; background:silver; height: 400px;}
$(document).ready(function() {
$('#tabela1').dataTable( {
"bPaginate": true,
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "server_processing.php"
} );
} );
Cliente
Funcionário
Produto
Serviço
Código
Nome
Endereço
Cidade
Complementp
Cep
Rg
Cpf
Uf
Telefone
Celular
[/code]
[code]<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array ('codigo', 'nome', 'endereco', 'cidade', 'complemento', 'cep', 'rg', 'cpf', 'uf', 'telefone1', 'telefone2', 'email');
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "codigo";
/* DB table to use */
$sTable = "id";
/* Database connection information */
$gaSql['user'] = "robson";
$gaSql['password'] = "1234";
$gaSql['db'] = "tcc";
$gaSql['server'] = "localhost";
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* Local functions
*/
function fatal_error ( $sErrorMessage = '' )
{
header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
die( $sErrorMessage );
}
/*
* MySQL connection
*/
if ( ! $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) )
{
fatal_error( 'Could not open connection to server' );
}
if ( ! mysql_select_db( $gaSql['db'], $gaSql['link'] ) )
{
fatal_error( 'Could not select database ' );
}
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
intval( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i[/code]
This discussion has been closed.