Hi, I'm new to jQuery and DataTable, I'm wondering how to use DataTables in ASP.NET applications, especially how to make Ajax call to web service. You know the asp.net web service will return json like this:
Following is my client side code:
And my web service method:
Could anybody guide me how to use DataTables AJAX in ASP.NET? Any help is appreciated! Thanks in advance!
Best Regards,
Sven [A guy from China]
{"d":[{"__type":"DataAccessLayer.CustomerInfo","CustomerID":1,"Name":"Google","Subsidiary":"G","ConfigName":"Gconfig"}], ....}DataTables will recognize this format as invalid.
Following is my client side code:
$(document).ready(function () { $("#CustomerTable").dataTable({ "bProcessing": true, "bServerSide": true, "sAjaxSource": "WebServices/CustomerService.asmx/GetCustomers", "fnServerData": function (sSource, aoData, fnCallBack) { $.ajax({ type: "POST", dataType: "json", url: sSource, //data: aoData, contentType: "application/json; charset=utf-8", success: fnCallBack }); } }); });
And my web service method:
[WebMethod] public List<CustomerInfo> GetCustomers() { CustomInfoBll ci = new CustomInfoBll(); return ci.GetCustomers(); }
Could anybody guide me how to use DataTables AJAX in ASP.NET? Any help is appreciated! Thanks in advance!
Best Regards,
Sven [A guy from China]