Character issue

Character issue

SebSeb Posts: 5Questions: 0Answers: 0
edited November 2011 in General
Hey all,

iam writing my table contents into a txt file for some speed reasons and works fine, except when there are some characters in the aaData field. Iam not entirely sure which characters that are.

iam calling the tables as below
[code]
$.getJSON("dataset.txt", function(data) {
    $('#test').dataTable( {
"bProcessing": true,
"sPaginationType": "full_numbers",
"aaSorting": [[1, 'asc']],
"aaData": data.aaData,
etc..
etc..
[/code]

Could someone point me to the allowed characters when using this method?

things i tried in php before writing this to the .txt file.
- trim()
-strip_tags()
-htmlentities()
- preg_replace ( only allow a-z 0-9) - works but dont really wanna go this far

So i guess its either some character like $ { which dont get replaced, or encoded entities which are not allowed.

Thanks for tips and pointers to the right direction, very nice script

Replies

  • SebSeb Posts: 5Questions: 0Answers: 0
    Found the issue, someone was using a backslash, which broken the data. Are there any more characters like these i should look out for?
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    If you are using PHP 5.2+ then I've very much suggest using json_encode() since that will take care of everything for you. Also you can try passing your JSON through http://jsonlint.com if you aren't sure where a formatting problem is, and it will take you straight to it :-)

    Allan
This discussion has been closed.