Refresh table after ajax success

Refresh table after ajax success

subzerillosubzerillo Posts: 2Questions: 0Answers: 0
edited December 2012 in DataTables 1.9
Hello.

First of all, thanks for creating such a great api to display awesome tables.

I have been struggling with the refreshing of the table for almost 2 days, searched for an answer on the documentation, and forums, but nothing is working for me.

Here is the debug of my datatable:
http://debug.datatables.net/itenus

My ajax to delete the row is working well, but after the ajax is done. Im trying to update the table without any success
This is the code to ajax delete the row on the server side and then update the table:
[code]
$('#sortable-table tbody').click(function(e){
$(oTable.fnSettings().aoData).each(function(){
$(this.nTr).removeClass('row_selected');
});
$(e.target.parentNode).addClass('row_selected');
})

function fnGetSelected( oTableLocal )
{
var aReturn = new Array();
var aTrs = oTableLocal.fnGetNodes();

for ( var i=0 ; i

Replies

  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    edited December 2012
    Just wondering - since you are deleting in the database and updating, fnDeleteRow seems unnecessary. fnDraw should do the trick. Again fnReloadAjax calls fnDraw if bServerSide is set to true which in your case is set to true.
  • subzerillosubzerillo Posts: 2Questions: 0Answers: 0
    Hi girishmr

    Thanks for your answer.

    But already tried all those combinations.

    Tried this:
    [code]
    $.ajax ({
    type: "POST",
    url: BASE + '/destroy',
    data: { deleteID : deleteID }
    }).done(function(data){
    oTable.fnDraw(true);
    });
    [/code]

    and this:
    [code]
    $.ajax ({
    type: "POST",
    url: BASE + '/destroy',
    data: { deleteID : deleteID }
    }).done(function(data){
    oTable.fnReloadAjax();
    });
    [/code]

    All with the same result, not refreshing my datatable on the browser.

    If someone could guide through the process of a simple datatable refresh with server side processing, I will be very grateful.

    Thanks.
  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    Can you verify whether the ajax call returns a success? Can you put an alert or console.log and see if there is an error in your ajax call.
This discussion has been closed.