Ajax error with server response HTTP ERROR 500

Ajax error with server response HTTP ERROR 500

User123456User123456 Posts: 57Questions: 15Answers: 0
edited September 2017 in Free community support

I run into this problem:

DataTables warning: table id=publicationTable - Ajax error. For more information about this error, please see http://datatables.net/tn/7

And this returns in the console:

POST http://sandbox.mettacontabilidade.com.br/lib/publicationProcessing.php 500 (Internal Server Error)

Followed tech notes advices howerever was empty Apache Log.

Can you help me? You can see the error reproduced here http://sandbox.mettacontabilidade.com.br/listPublication.php

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,143Questions: 26Answers: 4,918
    edited September 2017

    The 500 error is coming from your server. Not sure what you are using for your server side application but typically when I receive a 500 error its due to an issue with my sql query syntax or incorrect field names.

    What are you using for your server side code. Maybe you can post it for review.

    Kevin

  • User123456User123456 Posts: 57Questions: 15Answers: 0

    Of course @kthorngren, here is my server side from publicationProcessing:

    <?php
    include( "php/Datatables.php" );
    use
        DataTables\Editor,
        DataTables\Editor\Field;
    
    Editor::inst( $db, 'tbl_publication AS p', 'id_Publication' )
        ->fields(
            Field::inst( 'p.id_Publication' ),
            Field::inst( 'p.status' ),
            Field::inst( 'p.caminhoArquivo' ),
            Field::inst( 'p.ano' ),
            Field::inst( 'p.competencia' ),
            Field::inst( 'ti.tituloPublicacao' ),
            Field::inst( 'ty.tipoPublicacao' ),
            Field::inst( 'c.razaoSocial' ),
            Field::inst( 'e.nome' )
        )
        ->leftJoin( 'tbl_ptitle AS ti', 'p.fk_titulo', '=', 'ti.id_PublicationTitle' )
        ->leftJoin( 'tbl_ptype AS ty', 'p.fk_tipo', '=', 'ty.id_PublicationType' )
        ->leftJoin( 'tbl_company AS c', 'p.fk_empresa', '=', 'c.id_Company' )
        ->leftJoin( 'tbl_employee AS e', 'p.fk_empregado', '=', 'e.id_Employee' )
        ->process($_POST)
        ->json();
    

    Just to clarify, there were no errors on localhost.

  • User123456User123456 Posts: 57Questions: 15Answers: 0
    edited September 2017

    This is just a comment to clarify that what is happening is that the file publicationProcessing.php is being blocked. And I need it to return the data in my table
    @allan and @kthorngren.

    The problem being reported is HTTP ERROR 500. My log error only have this related to today:

    206.41.161.152 - - [08/Sep/2017:03:30:36 -0300] "GET / HTTP/1.1" 302 230 "-" "=Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16"

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited September 2017

    The browser console shows errors in listPublications.php.

    Also you are probably looking at the wrong error log. A 500 will have been logged somewhere.

    You should find out what your SQL query looks like. Try enabling the Editor debug mode.

  • User123456User123456 Posts: 57Questions: 15Answers: 0

    In the link I gave @tangerine?

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Yes.

  • User123456User123456 Posts: 57Questions: 15Answers: 0
    edited September 2017

    Didn't found one publications. The referer in the console is: https://www.sandbox.mettacontabilidade.com.br/listPublication.php.

    Isn't here correct @tangerine ?

  • User123456User123456 Posts: 57Questions: 15Answers: 0
    edited September 2017

    Here is a debug I did now @tangerine (cc @kthorngren ) https://debug.datatables.net/akenas.

    In advance I see that is a problem related with jQuery (I think):

    jquery-3.2.1.min.js:4 POST https://www.sandbox.mettacontabilidade.com.br/lib/publicationProcessing.php 500 ()

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    My mistake, I meant "listPublication.php".

  • User123456User123456 Posts: 57Questions: 15Answers: 0
    edited September 2017

    Okay @tangerine. And about the errorLog:

    You can see by yourself that is empty.

  • kthorngrenkthorngren Posts: 21,143Questions: 26Answers: 4,918

    I'm not familiar with the PHP libraries but if I remember correctly Allan has had people put ->debug( true ) immediately before ->process(...) to see the JSON response from the server and the SQL query.

    I would manually execute the SQL query.

    Kevin

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Answer ✓

    Yes, the ->debug() method is useful when there is an SQL error - but this appears to be a bit more fundamental than that so it won't give anything helpful in this case I'm afraid.

    A 500 error indicates that there was an error executing the PHP script. That could be anything from it being PHP 5.3 or earlier to there being a syntax or configuration error.

    You would need to check the server's error log. The log entry above appears to be an access log. The error log should be somewhere like /var/log/apache2/error_log, although its exact location will depend very much upon your server's configuration.

    Allan

  • User123456User123456 Posts: 57Questions: 15Answers: 0
    edited September 2017

    I solved the first problem @allan, using your advice. This error_log was very hard to find, but after hours looking in folders I managed to find and the error was related to the casing (the web server is very case sensitive), in localhost:

    Datatables.php was found

    But in the web server I had to find rename publicationProcessing to look for:

    DataTables.php

This discussion has been closed.