DataTable ServerSide .NET WebMethods
DataTable ServerSide .NET WebMethods
Hi All, my dataTable is not showing results although i get correct response from the server.
- I'm using ASP.NET <b>WebMethod behind the same page<b> NOTa dedicated aspx/asmx page.
my debug code: http://debug.datatables.net/izabir
my table configuration in client side script.
var table = $('#sample_editable_1');
var oTable = table.dataTable({
"pageLength": 5,
"serverSide": true,
"processing": true,
"ajax": {
"type": "POST",
"contentType": "application/json",
"url": "su_new.aspx/FN_GET_DEPENDANTS_LIST", // ajax source
"data": function (d) {
//return $.extend({}, d,
// JSON.stringify({ iMain_App_UUID: $("#txt_su_uuid").val() })
// );
//d.iMain_App_UUID = $("#txt_su_uuid").val();
//alert(JSON.stringify(d));
return JSON.stringify({ iMain_App_UUID: $("#txt_su_uuid").val() });
},
"success": function (data) {
var json = JSON.parse(data.d);
alert(data.d);
//return data.d;
return json;
},
},
});
HTML :
Port Ref | Nass Ref | Ho Ref | First name | last name | DOB | Gender | MArital Status |
---|---|---|---|---|---|---|---|
Port Ref | Nass Ref | Ho Ref | First name | last name | DOB | Gender | MArital Status |
Web Method response: (string)
{"draw":1,"recordsTotal":4,"recordsFiltered":4,"data":[["","15/08asd3)","","Shasdkte","Ksdka","2","2","16/12/1992 00:00:00"],["","15/08/0sd","","Fasdsdjona","Kasdsdka","1","1","14/asd000 00:00:00"],["","15/08asd6(1)","","asdbi","Koka","2","1","13/06/1963 00:00:00"],["","15/08/","","Rubina","Kasda","1","1","03/08/1995 00:00:00"]]}
when I check application Insights, i can see a successful request is being made and above response received from server:
although .NET servers return json response like this
{ "d": {json_result_Array}}
i have tried to extract the result array in the on success function like this:
"success": function (data) {
var json = JSON.parse(data.d);
alert(data.d);
//return data.d;
return json;
},
but still the no results are bing shown on the table. Am i missing anything?
many thanks
krish
Answers
for googlers:
i've added this part to the ajax call and all working as expected.