Does anyone know of any samples that use the DataTables jquery plugin with a WCF service?
I'm attempting to use a WCF service with the JavaScriptSerializer which unfortunately seems to return dodgy JSON by adding extra backslashes. However the DataTables would seem to provide a way to work around that given that the retrieval of the JSON can be handed off to a jQuery call. I'm not familiar enough with jQuery to get it working though.
My javascript is:
$(document).ready(function () {
$('#example').dataTable({
"bJQueryUI": true,
"bSort": true,
"bProcessing" : true,
"bServerSide" : true,
"bAutoWidth": true,
"sAjaxSource": "http://10.1.1.7/mvc-jqdatatable/datatabletestservice.svc/gettable",
"fnServerData": function(sSource, aoData, fnCallback) {
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} )
},
});
});
My WCF service is spitting out:
HTTP/1.1 200 OK
Content-Length: 56
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Thu, 23 Sep 2010 12:37:24 GMT
"{\"aaData\":[[\"a\",\"b\",\"c\"],[\"d\",\"e\",\"f\"]]}"
The JSON string is getting to the DatatTables script but it's not being recognised as JSON and is getting an error of:
'aaData.length' is null or not an object