I am currently trying to implement the jquery datatables extension to produce a table of live results. These results are caused by my code behind function calling another web service.
I have javascript gathering my parameters and im am using the jquery.ajax() function to talk to my code behind function. The datatables function require JSON in the following format
{
"aaData": [
[
"Trident",
"Internet Explorer 5.0",
"Win 95+",
"5",
"C"
]
]
}
I dont know how to get my functions response e.g. a string of comma separated information into the above format.
I have looked into json.net extension but I am not sure what approach to take. Considering that ever time my function runs I will be adding to the JSON which will need to be in a .txt file for datatables
Any suggestions appreciated!
Thanks
Code I currently have
var oTable;
$(document).ready ( function(){
oTable=$('#mytable').dataTable({
"sAjaxSource": 'TestData.txt'
});
});
and to call my code behind and get a string back
function asyncServerCall(inputs) {
jQuery.ajax({
url: 'Process.aspx/SearchBtnAjax',
data: JSON.stringify({ cities: inputs }),
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
alert(data.d);
oTable.fnReloadAjax();
}
});
}