javascript - Datatables use XML for serverside response -


i have custom web service have made answer datatables call (to handle paging , search)

according docs, tried use ajax.datasrc function manyaly parse xml data expected format.

$("#mytable").datatable({         serverside: true,         ajax: {             url: urlroot + "/ws/xxxx/yyyyy",             datasrc: function (data) {                 console.log("data");                 console.log(data);             },             type: "post"         }     }); 

however datasrc function not called , i'm granted messagebox alert saying json invalid ...

answer below :

the problem datatable jquery ajax call configured datatype: "json"inside datatables plugin itself, causing ajax call fall in error case server header replied text/html content type...

the solution add datatype: "text", in ajax options override behavior, follow :

$("#incidenttable").datatable({         serverside: true,         ajax: {             url: urlroot + "/ws/xxxx/yyyyy",             datatype: "text",             datasrc: function (data) {                 console.log("data");                 console.log(data);             },             type: "post"         }     }); 

and datasrc correcly called, allowin manualy parse data want.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -