Table not updating. Stuck with "processing" when ordering column with server side data.

Table not updating. Stuck with "processing" when ordering column with server side data.

ibdfariaibdfaria Posts: 15Questions: 4Answers: 0
edited April 2015 in Free community support

I am new to using this plugin with ajax. I got the plugin to render the rows just fine, but as soon as I click on the table header to order the column, the table doesn't update (the message "processing" never goes away either. I checked chrome devtools and I can see that the response was sent correctly. I validated my json, and that's also correct. After the data is retrieved, do I need to do anything to trigger the table update?

$('table.archive').dataTable({

    "processing":true,
    "serverSide":true,
    "ajax":{

        url:myajax.ajaxurl,
        data: {"action":"load_archives"}

    },
    "columnDefs": [
        { "name": "post_title",   "targets": 0 },
    ]

});

This question has an accepted answers - jump to answer

Answers

  • spradeeshspradeesh Posts: 7Questions: 2Answers: 0

    Hi, me too facing the same issue . In addition to that, am facing the same issue when i call FnDraw after edit/delete. You got any fix ?

  • ibdfariaibdfaria Posts: 15Questions: 4Answers: 0

    Nope. I am able to sort the table once from 10 entries to 25 entries. But anything else I try to do I get the "processing" message. How to troubleshoot issues like this?

  • spradeeshspradeesh Posts: 7Questions: 2Answers: 0

    Issue got fixed, Earlier i was passsing 1 by default to sEcho variable from server side. I changed that to sEcho = param.sEcho. Now it works fine.

  • ibdfariaibdfaria Posts: 15Questions: 4Answers: 0

    I solved my issue by setting "draw" to 1. No where in the docs it says that "draw" needs to be 1.

  • allanallan Posts: 61,950Questions: 1Answers: 10,158 Site admin

    The documentation for server-side processing says of the draw parameter:

    The draw counter that this object is a response to - from the draw parameter sent as part of the data request. Note that it is strongly recommended for security reasons that you cast this parameter to an integer, rather than simply echoing back to the client what it sent in the draw parameter, in order to prevent Cross Site Scripting (XSS) attacks.

    Since DataTables never sends draw as 0, it should never be returned as 0 (assuming that was the issue). As the documentation says, it should be returned as the same value that was sent (cast as an integer)

    Allan

  • ibdfariaibdfaria Posts: 15Questions: 4Answers: 0

    I have been reading the documentation for a week or so now, trying to find the issue. I read the paragraph many times, and didn't come to that conclusion. I guess the problem is me, but it's really not all that clear.

  • allanallan Posts: 61,950Questions: 1Answers: 10,158 Site admin

    Can you suggest what would make it clearer? I would obviously like it to be clear!

  • ibdfariaibdfaria Posts: 15Questions: 4Answers: 0

    Allan,

    I don't mean to complain. You have done a wonderful job providing this plugin. Thank you!

    The documentation lingo seems a bit hard to understand, but that's probably just me.

    This makes perfect sense:
    "it should be returned as the same value that was sent (cast as an integer)"

    But this paragraph is hard for me to understand:
    "The draw counter that this object is a response to - from the draw parameter sent as part of the data request."

    I just need to know that the draw number is sent on the request and that I should return that same value as an integer.

    Since I am new to datatables. I thought that the draw vlaue would correspond to the amount of rows returned. I didn't understand in the beginning that this number was already set for me and that I just had to return it.

    Anyway, it was my misunderstanding.

  • allanallan Posts: 61,950Questions: 1Answers: 10,158 Site admin
    Answer ✓

    No - I appreciate your feedback! I need feedback in order to improve the documentation - stuff that makes sense in my head doesn't always make sense externally. I'll rewrite that paragraph based on your note.

    Thanks,
    Allan

This discussion has been closed.