Coding characters problem

Coding characters problem

djohdjoh Posts: 23Questions: 0Answers: 0
edited November 2009 in Bug reports
Hi,

I have some coding issues in my tables, making the data not displayed while using bServerSide and sAjaxSource (php).

New entries'text to display is saved in a Mysql with UTF-8 encoding set. I'm not parsing, coding or modifying the data at the moment it is saved. Should I do anything there ?

When I want to display the data, some pages will simply not display. I cannot figure what is blocking the process... I'm opening the GET request by using firebug, and the output seems fine to me ! There's no single quote or double quote blocking the way, symbol like & are encoded ( & a m p ; ) etc.

Is there any character which I need to remove ?
The only way I managed to display the page was to remove all characters which are not letters or numbers (even spaces): preg_replace("/[^\w\d]+/i", '', $value)


Any idea what could cause the problem ?
I don't have any experience with text encoding...

Thanks in advance

Replies

  • allanallan Posts: 62,272Questions: 1Answers: 10,212 Site admin
    Hi djoh,

    Possible a character escaping issues? Have you tried running the JSON returned from the server through http://www.jsonlint.com ?

    Regards,
    Allan
  • djohdjoh Posts: 23Questions: 0Answers: 0
    Not of my output validates, including the one which is actually working...

    Does not pass JSON validation, but displays properly :
    [code]{"iTotalRecords": 1235, "iTotalDisplayRecords": 1235, "aaData": [ ['4','2009-06-25','1','1','1179','','0000-00-00','','','IDN-1-1.pdf','M'],['5','2009-07-05','109002','1','1460','Coil Strand 15.7 fasten','2009-06-01','','CS-001','IDN-109002-1.pdf','M'],['6','2009-07-05','999999','1','1898','Coil Strand 15.24 fasten','2009-07-02','','CS-002','IDN-999999-1.pdf','M'],['7','2009-07-05','1','2','0','Coil Strand 15.24 fasten','2009-07-04','External Truck','D.N. no. 7179','IDN-1-2.pdf','M'],['8','2009-07-05','10040','1','1877','PT Materials ','0000-00-00','','Yas Island','IDN-10040-1.pdf','M'],['9','2009-07-05','10006','1','1639','PT Materials','0000-00-00','','Amman developement project','IDN-10006-1.pdf','M'],['10','2009-07-05','10032','1','1900','PT Materials ','2009-07-02','','parallel Rd R 881 / 2C','IDN-10032-1.pdf','M'],['11','2009-07-05','10040','2','1457','Steel Fabrication ','2009-06-30','','SFB 001','IDN-10040-2.pdf','M'],['12','2009-07-06','20019','1','1870','Steel fabrication ','2009-07-02','','SFB 002','IDN-20019-1.pdf','M'],['13','2009-07-06','20019','2','0','Steel Fabrication ','2009-07-15','','SFB 003','IDN-20019-2.pdf','M']] }[/code]


    Anything wrong with my serverSide ?
    I've taken this one http://www.datatables.net/examples/data_sources/server_side.html and modified it to my needs...


    Thanks once again for your prompt reply, Allan !
  • djohdjoh Posts: 23Questions: 0Answers: 0
    Actually the source code of the JSON is

    [code]
    {
    "iTotalRecords": 1235,
    "iTotalDisplayRecords": 1235,
    "aaData": [
    [
    '1224',
    '2009-11-25',
    '909001',
    '54',
    '3713',
    'V-700 and V-778',
    '0000-00-00',
    'Pick up by SPME driver',
    '',
    'ahah-909001-54.pdf',
    'M'
    ],
    [
    '1225',
    '2009-11-25',
    '109005',
    '35',
    '3714',
    'Small consumables',
    '0000-00-00',
    'Pick up by Renown',
    '',
    'ahah-109005-35.pdf',
    'M'
    ]
    ]
    }
    [/code]

    Validation stops after 1224, and I don't know why ...
  • allanallan Posts: 62,272Questions: 1Answers: 10,212 Site admin
    Hi djoh,

    It stops at 1224 because 'string' isn't actually valid json - it should be double quotes ( "string" ). But that shouldn't stop it from being parsed correctly by the browser - jsonlint.com is strict. One thing I notice here is that you aren't returning 'sEcho'. I think it's optional (from memory), but it's a good idea to include it.

    I've just tried changing your json to be strictly valid, and it looks okay - so it's not that... I've just remembered that there was a post about something like this a while back: http://datatables.net/forums/comments.php?DiscussionID=675 - is the information in there of any use?

    Regards,
    Allan
This discussion has been closed.