how is this possible

how is this possible

javismilesjavismiles Posts: 205Questions: 38Answers: 3
edited March 2014 in Editor
I love the https://editor.datatables.net/,
its a great idea and features are perfect, i really love it

i want to purchase it so i am testing it with the generator, generating code for simple tables,
but 80% of times when i run it i get this error:
DataTables warning: JSON data from server could not be parsed. This is caused by a JSON etc etc

its very frustrating, how is this possible, this seems far too inestable unless i am missing something very basic in here

i am testing it with simple things like a couple of text fields in a table of my database, sometimes it works
but most times gives that error with short or long tables

please help

Replies

  • javismilesjavismiles Posts: 205Questions: 38Answers: 3
    i managed to debug it with firebug and solve it , we can close this, thank you :)
  • allanallan Posts: 61,892Questions: 1Answers: 10,144 Site admin
    For anyone else who reads this, the error message basically means what it says - the returned data is not valid JSON. Which typically means that there is an error message in the data, which will indicate what the issue is. This tech note can be used to determine what the error is: http://next.datatables.net/manual/tech-notes/1

    @javismiles - What was the error?

    Allan
  • javismilesjavismiles Posts: 205Questions: 38Answers: 3
    Thank you dear Allan,
    in the end i used Google Chrome Debugger to easily see the ajax errors being returned,
    that way its very easy to find out what's wrong,
    in my case there were two big issues that i feel you should alert people more clearly about

    1) The default primary key is always assumed to be ID, in one of my tables was USERID, this broke it all, so i had to set default to USERID and then it worked
    // $this->pkey( $pkey );
    $this->pkey( "userid" );

    2) DATES fields, timeZone not set in PHP, i had to set it to make it work
    in files format and validate of editor
    like this:
    namespace DataTables\Editor;
    date_default_timezone_set('America/Los_Angeles');
    same in both files

    Im a developer and i know how hard is to cover all cases in auto generating tools so i totally understand its not possible to explain all these little details in any case
  • allanallan Posts: 61,892Questions: 1Answers: 10,144 Site admin
    > 1) The default primary key is always assumed to be ID, in one of my tables was USERID, this broke it al

    Agreed! I did actually have a pkey field in the original version of generator, and then simplified it... I'm going to put it back in.

    > 2) DATES fields, timeZone not set in PHP, i had to set it to make it work

    I might put that in an FAQ, but it is a fairly generic PHP issue. I'll see if it comes up again (at which point it will become an FAQ :-) ).

    Thanks for the feedback!

    Allan
This discussion has been closed.