DataTables warning: JSON data from server could not be parsed. IE x Chrome

DataTables warning: JSON data from server could not be parsed. IE x Chrome

lusabolusabo Posts: 18Questions: 0Answers: 0
edited April 2012 in General
Hi all,

I've the JSON below validated by jsonlint. On IE occurs the error "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error." and on the Chrome the tables loads well. How to fix it?

[code]
{
"aaData": [
{
"CODIGO": "1",
"NOME": "Relator",
"TIPO": "Processo"
},
{
"CODIGO": "2",
"NOME": "Redator designado para redigir o voto vencedor",
"TIPO": "Processo"
},
{
"CODIGO": "3",
"NOME": "Redator de declara��o de voto",
"TIPO": "Processo"
},
{
"CODIGO": "4",
"NOME": "Redator de resolu��o",
"TIPO": "Processo"
},
{
"CODIGO": "5",
"NOME": "Redator de voto vencedor da resolu��o",
"TIPO": "Processo"
},
{
"CODIGO": "6",
"NOME": "Redator de declara��o de voto em resolu��o",
"TIPO": "Processo"
},
{
"CODIGO": "7",
"NOME": "Redator de despacho",
"TIPO": "Processo"
},
{
"CODIGO": "8",
"NOME": "Processo com vista registrada em ata",
"TIPO": "Processo"
},
{
"CODIGO": "9",
"NOME": "Processo em an�lise no m�s ou aguardando sa�da/julgamento",
"TIPO": "Processo"
},
{
"CODIGO": "20",
"NOME": "Compensa��o",
"TIPO": "Afastamento"
},
{
"CODIGO": "21",
"NOME": "F�rias",
"TIPO": "Afastamento"
},
{
"CODIGO": "22",
"NOME": "Lincen�as m�dicas",
"TIPO": "Afastamento"
},
{
"CODIGO": "23",
"NOME": "Aus�ncias justificadas",
"TIPO": "Afastamento"
},
{
"CODIGO": "24",
"NOME": "Convoca��es Subsecretarias",
"TIPO": "Afastamento"
},
{
"CODIGO": "25",
"NOME": "Convoca��es CARF/Coger/Audit",
"TIPO": "Afastamento"
},
{
"CODIGO": "30",
"NOME": "Atividades de delegado",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "31",
"NOME": "Atividades de presidente",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "32",
"NOME": "Sess�es",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "33",
"NOME": "Atualiza��o di�ria",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "34",
"NOME": "Reuni�es t�cnico-administrativas",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "35",
"NOME": "Eventos PROCAD",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "40",
"NOME": "Eventos N�O PROCAD",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "41",
"NOME": "Outros trabalhos na DRJ/RFB",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "42",
"NOME": "Atividades n�o especificadas",
"TIPO": "Atividades Administrativa Interna"
},
{
"CODIGO": "50",
"NOME": "Compensa��o",
"TIPO": "Compensa��o"
}
]
}
[/code]

Replies

  • lusabolusabo Posts: 18Questions: 0Answers: 0
    My jQuery
    [code]
    $('#listaCodigosRHAP').dataTable({
    "bPaginate": false,
    "bLengthChange": false,
    "bFilter": false,
    "bSort": false,
    "bInfo": false,
    "bDestroy": true,
    "oLanguage": {
    "sProcessing": "Carregando ...",
    "sZeroRecords": "Não existe(m) código(s) RHAP(s) para este tipo de unidade."
    },
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "ControleCodigoRHAP.asp",
    "fnServerParams": function ( aoData ) {
    aoData.push( { "name": "psAcao", "value": "obterlistacodigosrhap" } );
    aoData.push( { "name": "psTipoUnidade", "value": psTipoUnidade } );
    },
    "aoColumns": [
    { "sTitle": "Código", "mDataProp": "CODIGO", "sWidth": "20%" },
    { "sTitle": "Nome", "mDataProp": "NOME", "sWidth": "40%" },
    { "sTitle": "Tipo", "mDataProp": "TIPO", "sWidth": "40%" }
    ]
    });
    [/code]
  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    It looks like it should work - can your run your table through the DataTables debugger please?

    Allan
  • lusabolusabo Posts: 18Questions: 0Answers: 0
    Allan, how to do that?
  • lusabolusabo Posts: 18Questions: 0Answers: 0
    Allan,
    I'm running in IE and only appear two box, one green and one black and the letters doesn't appears.
    Luciano
  • lusabolusabo Posts: 18Questions: 0Answers: 0
    Allana,

    debug code: ajotij
  • lusabolusabo Posts: 18Questions: 0Answers: 0
    Allan,

    Using the debugger, the JSON is coming broken:

    [code]
    , {
    "CODIGO": "32",
    "NOME": "Sess￿," <-- Broken here
    TIPO ":"
    Atividades Administrativa Interna "},{"
    CODIGO ":"
    33 ","
    NOME ":"
    Atualiza￿di￿a ","
    [/code]

    Should be a charset problem?
  • allanallan Posts: 63,810Questions: 1Answers: 10,516 Site admin
    Yes it is possible - in fairness it could also be the debugger not coping with that situation, however, given that you are getting the warning you are, I'd suspect that the code is doing something odd. Do you have charset="utf-8" on all your Javascript tags? And the page is UTF-8?

    Allan
  • lusabolusabo Posts: 18Questions: 0Answers: 0
    The tags area with utf-8, but, the page is ISO-8859-1.
  • lusabolusabo Posts: 18Questions: 0Answers: 0
    I did a test here, only the character õ when inserted direct into the datanase is broken, when I insert by application it did not occur.
  • lusabolusabo Posts: 18Questions: 0Answers: 0
    Allan,

    I already tried a lot of possible solutions, like:

    - Use the commando Response.charset="iso-8859-1" and Response.charset="utf-8" before send the data.
    - Put the charset atribute in the script tag

    My page should have charset iso-8859-1 because the language user is Brazilian Portuguese.

    The problem with accentuation is not resolved and the character õ is breaking the JSON.

    Please help me!!!
This discussion has been closed.