Server-side doesn't work... SOMETIMES?

Server-side doesn't work... SOMETIMES?

birdj1birdj1 Posts: 11Questions: 2Answers: 0

Hi, this is a strange one!

I have server-side processing set up and it works, sometimes..? If I search for certain letters "Hell." I get an AJAX error, but if I press okay on all of those errors and have one more letter, searching this time for "HELLO" I get one result from the database as the description field contains the term "Othello". The AJAX response from those first four letters is completely empty, whereas the five letters returns all of the data inserted containing the term "Othello"

The same goes for my name. If I want to find the job that contains "Set the email address up for Jordan", searching "Jo" will give me an empty ajax response and error, but "Jor" will find the result that contains Jordan.

If I click results-per-page, they work. Unless I select 50 or 100, in which case the AJAX response is empty. 10 and 25 work fine.

If on the pagination I click through, it works fine, unless I click page 5, in which case the AJAX response is empty.

If I try and sort by the description field by clicking on the table header, I get an empty AJAX response.

Really weird bugs going on and I have no idea what to do. I've been fiddling with the code all week and time constraints mean I will need to switch to a different jQuery data table library if I can't sort it. I like the look of DT with all the extensions so I'd really like to fix this if possible.

Here is my debug data: http://debug.datatables.net/afuliw

Thank you!

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    There is a strong possibility that the problem is with the back end, not datatable. I first step is see what is being passed to the server when things are working right, vs what is passed when things are not right.

  • birdj1birdj1 Posts: 11Questions: 2Answers: 0
    edited April 2017

    @bindrid Hi, thanks for your reply! If I check the HTTP request for searching 'jo' (doesn't work) and then 'jor' (does work) then the requests are absolutely identical.

    The one difference is:
    search[value]:jo
    search[value]:jor

    Between the two requests. Everything else is identical. The second search term returns through ajax the search results for 'jor' - "Make new email address for Jordan...", whereas the ajax return from the search results for 'jo' is completely empty.

    If I echo "results: " . [ajax] then the ajax data will have that "results :" string within it, yet 'jo' means nothing comes afterwards, whereas 'Jor' returns "results : data" so the echo is still working regardless. Some reason my results are completely void of anything.

    I don't even get " {"draw":41,"recordsTotal":11952,"recordsFiltered":0,"data":[]}" which is what happens when there are no results. It's literally complete nothingness.

    EDIT: There is another difference that I missed!
    From the 'response headers'
    Working search: Content-Length:767
    Search that doesn't work: Content-Length:1

  • allanallan Posts: 63,175Questions: 1Answers: 10,409 Site admin

    Have a look at the server error logs. There is a good chance there will be an error reported there.

    My guess is that a search on jo is causing an SQL error or a character encoding error.

    Allan

  • birdj1birdj1 Posts: 11Questions: 2Answers: 0

    Hi @allan thanks for your reply,

    There are no new Apache or MySQL errors entered into their respective logs when the issue occurs. I feel like it's certain entries into the database that are causing errors (Ca't load page 6 etc.) but I'm not sure why because the data all seems to be the same, varchars with a length of 500.

    If I isolate the ten entries on page 6, and search for them one by one, a search term of one of the pieces of data throws up the error. This data is the same except possibly it contains a '£' sign in the information. This is the only difference really and as the field is a latin encoded Varchar, I don't see why it would be the cause of the issue.

    Thanks

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

    Please set up a working debug. The one you posted throws a 404.

  • birdj1birdj1 Posts: 11Questions: 2Answers: 0

    @tangerine Here is the new debug, the old one must have expired http://debug.datatables.net/ewaboq

  • allanallan Posts: 63,175Questions: 1Answers: 10,409 Site admin

    Could you show a debug trace from when it is in the error state please? i.e. search for 'jo' and then run the debugger.

    Thanks,
    Allan

  • birdj1birdj1 Posts: 11Questions: 2Answers: 0

    Hi @allan thanks for getting back to me. Here's the debugger whilst the table isn't working as I have typed "jo" into the box: http://debug.datatables.net/ukevem

    Thank you

  • allanallan Posts: 63,175Questions: 1Answers: 10,409 Site admin

    Thanks.

    It shows that the server (/utrak/ajax_requests/alljobs.php) is returning nothing. There is no valid JSON and no data at all which is why DataTables is showing an error.

    My first suggestion would be to check your server's error logs.

    Allan

  • birdj1birdj1 Posts: 11Questions: 2Answers: 0

    Hi @allan - The PHP request script is from the example on the guide above. Here's a paste of the script https://pastebin.com/kB2Wgg2r (/utrak/ajax_requests/alljobs.php)

  • allanallan Posts: 63,175Questions: 1Answers: 10,409 Site admin

    Did you take a look at the server's error logs?

  • birdj1birdj1 Posts: 11Questions: 2Answers: 0
    edited May 2017

    Unfortunately in the error logs there's just the warnings as usual, nothing is thrown up when the issue occurs

    Edit: I have a feeling that it's some data. It seems that page 6 has the same issue. Going into the SQL, I find the entries that would appear on page 6 and search for each one, and then one of them throws an error while searching. The thing is though, there's no difference in the data than any other entry. It's a varchar(300) encoded in Latin, just like all the rest.

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

    Your debug has server interaction as "Ajax HTTP method GET"
    but your server-side processing function expects $_POST.

This discussion has been closed.