Editor examples JSON parsing error

Editor examples JSON parsing error

DanSchwartzDanSchwartz Posts: 19Questions: 0Answers: 0
edited July 2012 in Editor
Allan or whoever,

I have installed the Editor trial version and tried to open

http://localhost/DataTablesEditor/DataTables-1.9.2/extras/Editor-1.1.0-Trial/examples/index.html

and am getting a popup saying

DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be
parsed. This is caused by a JSON formatting error.

Would you know how to fix this?

Thanks,

Dan Schwartz

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    If you look at the console in your browser, you'll see that DataTables is making an Ajax request to the server - what is the server returning?

    Have you installed the SQL and set up the database ( http://editor.datatables.net/tutorials/installing )?

    Allan
  • DanSchwartzDanSchwartz Posts: 19Questions: 0Answers: 0
    Allan,

    Here are the contents of the browser (Firefox) console:

    [13:46:34.686] Expected declaration but found '*'. Skipped to next declaration. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/media/css/jquery.dataTables.css:16
    [13:46:34.687]

    Unknown property '-moz-border-radius'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/media/css/jquery.dataTables.css:151
    [13:46:34.689]

    Expected declaration but found '*'. Skipped to next declaration. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/TableTools/media/css/TableTools.css:44
    [13:46:34.689] Unknown property '-moz-border-radius'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/TableTools/media/css/TableTools.css:49
    [13:46:34.689] Unknown property '-moz-box-shadow'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/TableTools/media/css/TableTools.css:55
    [13:46:34.689] Error in parsing value for 'background'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/TableTools/media/css/TableTools.css:62
    [13:46:34.689] Error in parsing value for 'filter'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/TableTools/media/css/TableTools.css:67
    [13:46:34.691] Expected declaration but found '*'. Skipped to next declaration. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/Editor-1.1.0-Trial/media/css/dataTables.edito

    r.css:131
    [13:46:34.691] Unknown property '-moz-border-radius'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/Editor-1.1.0-Trial/media/css/dataTables.edito

    r.css:150
    [13:46:34.691] Unknown property '-moz-box-shadow'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/Editor-1.1.0-Trial/media/css/dataTables.edito

    r.css:156
    [13:46:34.691] Error in parsing value for 'background'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/Editor-1.1.0-Trial/media/css/dataTables.edito

    r.css:163
    [13:46:34.691] Error in parsing value for 'filter'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/Editor-1.1.0-Trial/media/css/dataTables.edito

    r.css:168
    [13:46:34.692] Expected declaration but found '#position'. Skipped to next declaration. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/Editor-1.1.0-Trial/media/css/dataTables.edito

    r.css:235
    [13:46:34.692] Expected declaration but found '#top'. Skipped to next declaration. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/extras/Editor-1.1.0-Trial/media/css/dataTables.edito

    r.css:236
    [13:46:34.847] Unknown property '-moz-border-radius'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/examples/examples_support/syntax/css/shCore.css:27
    [13:46:34.847] Unknown property 'box-sizing'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/examples/examples_support/syntax/css/shCore.css:46
    [13:46:34.848] Error in parsing value for 'min-height'. Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/examples/examples_support/syntax/css/shCore.css:52
    [13:46:34.849] Expected color but found 'none'. Error in parsing value for 'background-color'.

    Declaration dropped. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/examples/examples_support/syntax/css/shCore.css:346
    [13:46:34.849] Expected declaration but found '*'. Skipped to next declaration. @

    http://localhost/DataTablesEditor/DataTables-1.9.2/examples/examples_support/syntax/css/shCore.css:365

    I believe I've set up the database properly. Here is the dp.php file:

    <?php

    error_reporting(E_ALL);
    ini_set('display_errors', '1');


    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * Database user / pass
    */
    $sql_details = array(
    "user" => "root",
    "pass" => "rootpwd",
    "host" => "localhost",
    "db" => "datatableseditor"
    );


    // This is included for the development and deploy environment used on the DataTables
    // server. You can delete this block - it just includes my own user/pass without making
    // them public!
    if ( is_file($_SERVER['DOCUMENT_ROOT']."/datatables/pdo.php") ) {
    include( $_SERVER['DOCUMENT_ROOT']."/datatables/pdo.php" );
    }
    // /End development include


    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * Database connection
    */

    /* PDO connection */
    /*
    $db = new PDO(
    "mysql:host={$sql_details['host']};dbname={$sql_details['db']}",
    $sql_details['user'],
    $sql_details['pass'],
    array(
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
    )
    );
    */

    /* mysql_* connection */

    if ( ! $db = mysql_pconnect( $sql_details['host'], $sql_details['user'], $sql_details['pass'] ) ) {
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( 'Could not open connection to server' );
    }

    if ( ! mysql_select_db( $sql_details['db'], $db ) ) {
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( 'Could not select database' );
    }



    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    * Include DTEditor class
    */

    // Include the DTEditor class that belongs with this connection type
    //include( dirname(__FILE__)."/DTEditor.mysql.pdo.class.php" );
    //include( dirname(__FILE__)."/DTEditor.postgres.pdo.class.php" );
    include( dirname(__FILE__)."/DTEditor.mysql.class.php" );
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Have a look at the XHR in Firebug. What does it say is being returned from the server?

    Allan
  • DanSchwartzDanSchwartz Posts: 19Questions: 0Answers: 0
    I've never used Firebug before but managed to install it. I don't know what "XHR" means, but this is
    what I see in the console:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">




    DataTables Editor example














    I'm running this inside Netbeans, and Netbeans shows an error on every CSS entry that starts with an
    "*", saying it's an "unexpected symbol". These correspond to the entries shown from the Firefox
    console shown in my previous post.

    Dan
  • DanSchwartzDanSchwartz Posts: 19Questions: 0Answers: 0
    Hello again, Allan,

    I just noticed that not all of the html nodes were not expanded in my previous posting. However, I've just tried posting the full version, and the post doesn't go through. Possibly it's too large.

    Dan
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    edited July 2012
    HI Dan,

    This video on Ajax debugging with Firebug will help: www.youtube.com/watch?v=W4jXAaEMp2M . Basically we need to know what is being returned from the server.

    > every CSS entry that starts with an "*", saying it's an "unexpected symbol"

    The star hack is for IE6 ( http://en.wikipedia.org/wiki/CSS_filter#Star_hack ). It introduces invalid CSS which everything else ignores, but that's the cost of IE6 support here.

    Allan
  • DanSchwartzDanSchwartz Posts: 19Questions: 0Answers: 0
    Hello Allan,

    That video didn't get through with the post. Can you send the URL?

    I have expanded that output from Firebug and posted a Notepad version at www.cs.fsu.edu/~schwartz/firebug.txt and a Wordpad version at www.cs.fsu.edu/~schwartz/firebug.rtf . Copying removed the formatting, so I hope you can make sense of it. I'm guessing that "XHR" means "XmlHttpRequest".

    My interpretation of that Wikipedia page regarding the star-hack is that everything should work fine despite the fact that I'm getting those error messages. Is this correct?

    Dan
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    > That video didn't get through with the post. Can you send the URL?

    I've edited my post so the URL is in plain text now. It was the first hit on google when I searched for "firebug ajax tutorial".

    > I'm guessing that "XHR" means "XmlHttpRequest".

    Yes :-). The files show the source for the page, but we are interested in the JSON that is being returned from the server here.

    > My interpretation of that Wikipedia page regarding the star-hack is that everything should work fine despite the fact that I'm getting those error messages. Is this correct?

    Correct - that has nothing to do with the JSON loading issue you are seeing. For that, as I say, you really need to know what the XHR is getting back from the server.

    Allan
  • DanSchwartzDanSchwartz Posts: 19Questions: 0Answers: 0
    Hello Allan,

    I'm not sure if this is what you want, but I enabled the Firebug Console and clicked on the Response tab, and this is what I found:



    Fatal error: Call to undefined function mysql_pconnect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\DataTablesEditor\DataTables-1.9.2\extras\Editor-1.1.0-Trial\examples\php\include\db.php on line 45


    The referenced line in db.php is

    if ( ! $db = mysql_pconnect( $sql_details['host'], $sql_details['user'], $sql_details['pass'] ) ) {
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( 'Could not open connection to server' );
    }

    Does this help? I did a search on the source code and couldn't find a definition for mysql_pconnect.

    Dan
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    That sounds like it! Yes that helps at lot.

    So basically your server is returning a 500 error because it can't find the function mysql_pconnect ( http://php.net/manual/en/function.mysql-pconnect.php ). That is the method that is being used to connect to your MySQL database (assuming you have one), but it sounds like your PHP install doesn't have the mysql_* functions compiled in (you can confirm with phpinfo).

    Does it have the MySQL PDO driver built in - you could use that instead?

    Allan
  • DanSchwartzDanSchwartz Posts: 19Questions: 0Answers: 0
    Hello Allan,

    I had decided to use Apache and, when I went to install PhP, the instructions said that Apache would not support PhP versions later that 5.2, and it seems that PDO wasn't included until version 5.3.

    After some rather extensive research, I've come to the conclusion that the only way to run the recent
    versions of PhP is on Windows with IIS. Do you agree with this?

    I would prefer to use something that's portable to Linux, but that doesn't seem to be possible right now.

    Dan
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    edited July 2012
    > the instructions said that Apache would not support PhP versions later that 5.2

    This server that datatables.net is on is using Apache with PHP 5.3 :-). PHP 5.4 is perfectly compatible with Apache as well.

    > After some rather extensive research, I've come to the conclusion that the only way to run the recent versions of PhP is on Windows with IIS. Do you agree with this?

    Not really no. Apache for Windows is excellent. Have a look at the WAMP distribution: http://www.wampserver.com/en/ . Apache 2.2/2.4 and PHP 5.3/5.4 available.

    Allan
  • DanSchwartzDanSchwartz Posts: 19Questions: 0Answers: 0
    Hello Allan,

    Okay, I got it working---finally! It hadn't occurred to me to look into the www.php.net archive, where I found a VC6 edition of PhP 5.3, which includes PDO. I installed this with Apache 2.2, and it did the job.

    I'm not sure if I will use the Editor in my applicaton, but I plan to buy a license so I can study it and
    learn how it works.

    Thanks for all you help,

    Dan
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Fantastic. Do let me know if you have any questions about it.

    Allan
  • OsirisOsiris Posts: 36Questions: 0Answers: 0
    Get apache 2.4 ?
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    @Osiris - I'm not sure sure I understand? This conversation is two months old now. Are you having a similar problem but with Apache 2.4?

    Allan
  • OsirisOsiris Posts: 36Questions: 0Answers: 0
    yes, ignore it, sorry.
    I solved the issue with the above comments ... well ... and switching to a different db aproach.
This discussion has been closed.