Invalid Json Response

Invalid Json Response

ITHWPITHWP Posts: 2Questions: 1Answers: 0

Hello,

I'm using the Datatables Editor Generator and after setting everything up using php, I'm still getting a

"DataTables warning: table id=NurseTechnician - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1"

I've set up my config.php file and when looking at the console i'm getting a successul connection to my database.

Answers

  • kthorngrenkthorngren Posts: 21,310Questions: 26Answers: 4,948

    Did you follow the troubleshooting steps provided in the link?
    http://datatables.net/tn/1

    Kevin

  • ITHWPITHWP Posts: 2Questions: 1Answers: 0

    I did,

    When checking the error the name shows up as

    http://[serverIP]/php/table.NurseTechnician.php?_=1551999811077

    and the response as:

    <?php
    
    /*
     * Editor server script for DB table NurseTechnician
     * Created by http://editor.datatables.net/generator
     */
    
    // DataTables PHP library and database connection
    include( "lib/DataTables.php" );
    
    // Alias Editor classes so they are easy to use
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;
    
    // The following statement can be removed after the first run (i.e. the database
    // table has been created). It is a good idea to do this to help improve
    // performance.
    
    
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'NurseTechnician', 'id' )
        ->fields(
            Field::inst( 'name' ),
            Field::inst( 'email' ),
            Field::inst( 'phone' )
        )
        ->process( $_POST )
        ->json();
    
  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @ITHWP ,

    As Kevin said, the first thing to do is to follow the diagnostic steps in that link. The most useful one for us to support you, is to find out what the JSON response actually is - it's claiming it's invalid, so it's probably failing to connect to the DB and posting an invalid string back.

    Cheers,

    Colin

This discussion has been closed.