DataTables server-side processing.

DataTables server-side processing.

theteo_brtheteo_br Posts: 4Questions: 1Answers: 0

Hello everyone,

I downloaded the example DataTables server-side processing.
When I use the table that is in the example (datatables_demo) works normally.

When I set up for one of my tables:

simple.html

<

table id = "example" class = "display" cellspacing = "0" width = "100%">
<thead>
<tr>
<th> Contrib </ th>
<th> protocolo </ th>
<th> assunto </ th>
<th> flag </ th>

</ tr>
</ thead>

<tfoot>
<tr>
<th> Contrib </ th>
<th> protocolo </ th>
<th> assunto </ th>
<th> flag </ th>

</ tr>
</ tfoot>
</ table>

server_processing.php

$ table = 'tbl_protocolos';

// Table's primary key
$ primaryKey = 'id_protocolo';

// Array of database columns Which Should be read and sent back to DataTables.
The parameter // db Represents the column name in the database, while thedt
// Parameter Represents the DataTables column identifier. In this simple case
// indexes
$ columns = array (
array ('db' => 'id_contrib', 'dt' => 0),
array ('db' => 'protocolo', 'dt' => 1),
array ('db' => 'assunto', 'dt' => 2),
array ('db' => 'flag', 'dt' => 3),

);

the invalid JSON response "tn / 1" error occurs.

Can anyone tell me why ?

Answers

  • theteo_brtheteo_br Posts: 4Questions: 1Answers: 0

    hey Alan, why MY TABLEe does not work, I can not understand why.?

    i put the name - tbl_protocolos
    i put ID - id_protocolo
    I put the name of columns as my table - id_servidor, id_contrib, protocolo, assunto, id_setor, flag
    iI put credences database.

    what else should I do?

  • theteo_brtheteo_br Posts: 4Questions: 1Answers: 0

    does not work just localhost, i dont know why.

    i make upload for my server and work.

  • theteo_brtheteo_br Posts: 4Questions: 1Answers: 0
    edited September 2014

    Doing some testing ....

    Using the example table (datatables_demo) works on localhost and web server.

    Using my table, works on the web server and NOT WORKS on localhost.

    INVALID JSON Response.

    Can anyone help me ??

  • theteotheteo Posts: 15Questions: 3Answers: 0

    so Alan, using xammp version 1.8.3 does not work.

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    xampp works fine for me.

    You should show more of your code (formatted using Markdown).

  • theteotheteo Posts: 15Questions: 3Answers: 0
    edited September 2014

    hey tangerine, can you tell me your xampp version ?

    Using the example table (datatables_demo) works on localhost and web server.

    Using my table, works on the web server and NOT WORKS on localhost.

    INVALID JSON Response.

    why ???

  • theteotheteo Posts: 15Questions: 3Answers: 0
    edited September 2014

    I need help, something weird is happening.

    I uploaded the plugin Datatables (http: //localhost/DataTables-1.10.2/examples/server_side/simplemylocal.html) and am trying to use the example server-side (DataTables-1.10.2 \ examples \ server_side \ simple. html)

    Well, in the example found himself a mysql table datatables_demo (mysql.sql)

    The problem:

    setting the \scripts\server_processing.php datatables_demo to read the table, everything works perfectly, localhost and the web.

    When set up with another table in my database, NOT localhost works, but works very well on the web.

    The question is, why?

    error: Datatables Warning: Invalid JSON response

    I have to think that the problem is my table.
    But if true, why it would work on the web?

  • theteotheteo Posts: 15Questions: 3Answers: 0

    so, I did some tests and find that the problem is in the words with accents, like á ão ç. How can I solve this?

  • theteotheteo Posts: 15Questions: 3Answers: 0
    edited September 2014

    SCRIPT

    
    $(document).ready(function() { 
    $('#example').dataTable( {
    "processing": true,
    "serverSide": true,
    "ajax": "scripts/server_processing.php" } );
    } );

    PHP

    
    $table = 'teste'; 
    $primaryKey = 'id_protocolo';
    $columns =
    array( array( 'db' => 'protocolo', 'dt' => 0 ),
    array( 'db' => 'assunto', 'dt' => 1 ) );
    $sql_details = array( 'user' => 'root', 'pass' => '*****', 'db' => 'banco', 'host' => 'localhost' );
    require( 'ssp.class.php' );
    echo json_encode( SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
    );
  • theteotheteo Posts: 15Questions: 3Answers: 0

    hey Alan, can you help-me ?

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    You need to read up on UTF-8. There are plenty of relevant posts in here for a start.

  • theteotheteo Posts: 15Questions: 3Answers: 0

    Tangerine,
    $mysqli->query("SET NAMES 'utf8'");
    $mysqli->query("SET character_set_connection=utf8");
    $mysqli->query("SET character_set_client=utf8");
    $mysqli->query("SET character_set_results=utf8");

    I'm already using it on my connection

  • theteotheteo Posts: 15Questions: 3Answers: 0

    hey tangerine I got, but now, please look that:
    http://stackoverflow.com/questions/26079486/return-value-on-button-datatable-server-side
    can you help-me ?

  • theteotheteo Posts: 15Questions: 3Answers: 0

    Alan, maybe can you help me

This discussion has been closed.