success and error ??

success and error ??

mv5492mv5492 Posts: 10Questions: 0Answers: 0
edited January 2010 in General
With $.ajax we get success: and error: options to trigger events as needed. I don't see these options for DataTable. I have tried using the load() function but I'm not getting it to work.

$(document).ready( function () {
$('#tableOne').dataTable( {
"bServerSide": false,
"bProcessing": false,
"sAjaxSource": 'http://ufpetl02a.edc.net/my.cgi'
} );
} );

$(tableDiv).load(function() { do something jqueryish... });

Is there a way to determine success and error?

Thanks,
Mike

Replies

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Hi Mike,

    The way to check for success or error at the moment is to see if it works or not :-). If it doesn't break out Firebug and jsonlint.com...

    So there currently isn't a way to do this other than to hack the DataTables code, or to wrap up your own Ajax call and pass it to DataTables as aaData (or fnAddData). However, I will look at abstracting out this function (like fnServerData does) for the next version.

    Regards,
    Allan
  • mv5492mv5492 Posts: 10Questions: 0Answers: 0
    Thanks again. I don't mean to keep you busy with new features, but thank you for adding to the list. I did not see fnServerData before but see it now, so I'll go play with it.

    I am hoping to be able to pull server data, present and change it in dataTable, and post the changes back to the server. If anyone has done this already I would love to see the result.

    Mike
  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Hi Mike,

    No problem at all - thanks for bringing it up. This has come up once or twice before, so it makes sense to include, particularly while I'm working on an update just now.

    fnServerData currently only has effect for server-side processing, but I think I will extend this to Ajax data loading as well, since the two data types can't be used at the same time.

    Regards,
    Allan
  • mv5492mv5492 Posts: 10Questions: 0Answers: 0
    I ended up using fnInitComplete to execute a function after the table was loaded. I'm not sure how correct it is to do this but I am getting the result I want.

    "fnInitComplete": function() {
    $(loading).replaceWith(" ");
    }

    I didn't have success with fnServerData, but i'll probably try again.
This discussion has been closed.