Warning: Ajax error

Warning: Ajax error

arnonrdparnonrdp Posts: 29Questions: 8Answers: 0

I am facing an Ajax Error. I used the debugger but didn't solve my problem.

Debugger code: https://debug.datatables.net/eheyiv
Error messages shown: 500 (Internal Server Error)

What am I missing?

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    A 500 is error is an error on the server, so you'll need to debug there. Start with the web-server logs, then any scripts you have,

    Colin

  • arnonrdparnonrdp Posts: 29Questions: 8Answers: 0

    When I comment this line require( 'ssp.class.php' ); it returns me Invalid JSON response.

    This is my server_processing.php:

        <?php
          header("Access-Control-Allow-Origin: *");
        /*
         * DataTables example server-side processing script.
         *
         * Please note that this script is intentionally extremely simple to show how
         * server-side processing can be implemented, and probably shouldn't be used as
         * the basis for a large complex system. It is suitable for simple use cases as
         * for learning.
         *
         * See http://datatables.net/usage/server-side for full details on the server-
         * side processing requirements of DataTables.
         *
         * @license MIT - http://datatables.net/license_mit
         */
         
        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         * Easy set variables
         */
         
        // DB table to use
        $table = 'cotacoes_opcoes_dia';
         
        // Table's primary key
        $primaryKey = 'id';
         
        // Array of database columns which should be read and sent back to DataTables.
        // The `db` parameter represents the column name in the database, while the `dt`
        // parameter represents the DataTables column identifier. In this case simple
        // indexes
        $columns = array(
            array( 'db' => 'codigo_neg_acao', 'dt' => 0 ),
            array( 'db' => 'codigo_neg',  'dt' => 1 ),
            array( 'db' => 'tipo_opcao',   'dt' => 2 ),
            array( 'db' => 'tipo_mercado',     'dt' => 3 ),
            array( 'db' => 'preco_exercicio',     'dt' => 4 ),
            array( 'db' => 'data_venc',     'dt' => 5 ),
            array(
                'db'        => 'preco_ult',
                'dt'        => 6,
                'formatter' => function( $d, $row ) {
                    return '$'.number_format($d);
                }
            ),
            array( 'db' => 'qtde_total',     'dt' => 7 ),
            array( 'db' => 'volume_total',     'dt' => 8 )
        );
         
        // SQL server connection information
        $sql_details = array(
            'user' => 'u437961929_admin',
            'pass' => '',
            'db'   => 'u437961929_rendaz',
            'host' => 'localhost'
        );
         
        echo "sql ".$sql_details;
        
        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         * If you just want to use the basic configuration for DataTables with PHP
         * server-side, there is no need to edit below this line.
         */
         
        //require( 'ssp.class.php' );
         
        //echo json_encode(
        //    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
        //);
    

    Do I need a ssp.class.php? Or do I need to turn my sql data to json?

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    You would need that file, as you've enabled serverSide. Did you look at the server logs as I suggested earlier?

    Colin

  • arnonrdparnonrdp Posts: 29Questions: 8Answers: 0

    Yes, I did! All I needed to do was to insert the ssp.class.php inside my server. Thank you so much!

    Everything seems to be working now: http://myoption.com.br/index.html

    But I took note that searching on a server-side table is different. It doesn't search on two different columns at the same time.

    Is there any possibility to make it search this way?

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    But I took note that searching on a server-side table is different. It doesn't search on two different columns at the same time.

    Yep, the smart search doesn''t work, as we would assume the volume of data needed for server-side data would make that inefficient You can update the supplied scripts to provide that functionality - there are a few threads, such as here, discussing that..

    Colin

This discussion has been closed.