Prep Data, what would break datatable

Prep Data, what would break datatable

bjohnbbjohnb Posts: 3Questions: 0Answers: 0
edited July 2010 in General
I've got a database which has simply got company information in such as company name, telephone number, revenue and business description.

It's my own data so there is nothing in there that could have been added by a third party and it's on a internal network too. So the data is safe. However, i'm outputting it and paging through it and sometimes it gets to a point where it says processing and wont load the next set of data. I can see the data in the ajax response from the server using firebug but that data is not being rendered in to datatables for some reason.

So far i'm htmlentities(addslashes($data)), is there anything else i should do to prep the data to make sure anything will get loaded?

Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited July 2010
    A null value would break DataTables 1.6 - the 1.7 betas convert null to an empty string. Also anything with invalid JSON would also break the table ( www.jsonlint.com ). Newlines are a fairly common one to break JSON since you can't have multi-line strings in Javascript without escaping them.

    Allan
  • bjohnbbjohnb Posts: 3Questions: 0Answers: 0
    Ahhh right, i think it maybe a null value then. Are the 1.7 betas fairly stable?!

    Thank you!
  • bjohnbbjohnb Posts: 3Questions: 0Answers: 0
    Thank you for that www.jsonlint.com link! I ran my output through it and it was actually single quotes that was breaking the json.

    I've added ENT_QUOTES to my htmlspecialchars and it's working like a dream.

    Thanks again!
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    1.7 beta 6 should be very stable - and baring any major incidents 1.7.0 will be released this coming weekend. There might be one more beta in the next few days (I've got one enhancement to make, and one possible bug fix).

    However it sounds like you've got it sorted now :-). The JSON parser in jQuery 1.4 is very particular about the formatting. 1.7 will give an alert error when this occurs...

    Allan
This discussion has been closed.