Server-side processing stuck on "processing" when handing "success" in ajax
Server-side processing stuck on "processing" when handing "success" in ajax
sittsen
Posts: 3Questions: 1Answers: 0
Referring to the discussion:
https://datatables.net/forums/discussion/26602/datatables-1-10-4-server-side-processing-stuck-on-processing-error-message
I am using DataTables 1.10.12. I am wondering if there is a way to draw the table after after handling ajax "success". If I do not intercept the success "event", everything works well.
This discussion has been closed.
Answers
The issue is that datatables is coded to use the success so if you intercept it, it breaks datatables.
The most common options around this is:
1. pull your ajax out of datatable and use the ajax success to initialize the table.
2. instead of using success:function(){} in the ajax that is in datatables, use dataFilter:function(resp(). This approach lets you "see" the data before it gets passed to success.
Its documented here http://api.jquery.com/jQuery.ajax/
Its a long thread but you can see an example here: https://datatables.net/forums/discussion/comment/109582#Comment_109582
Thank you bindrid. Would dataSrc be another option as I starting to see others suggesting that path. Do you know which is better?
It depends on what you are trying to accomplish.
dataSrc is used when the data is not where datatables expects to find it but it is in the format it expects.
you use dataFilter if the data is valid but not in the format that is expected. It lets you change it.
For example, when using use Microsoft asmx web services, you could end up with the data be serialized twice so, in my case, I deserialized it, twice, put it in the format expected and sent it on.
One other advantage of dataFilter is that it can assist with debugging, for example
by adding the dataFilter and the error sections, you can run this code with the console open and be able to drill down and see exactly what you got from the server and see what to do with it to have datatables except it
Thank you so much bindrid. I have gone for the dataSrc option as the data it serves my purpose. Thank you again.