Jquery DataTable fnServerData Error
Jquery DataTable fnServerData Error
I posted this question on stackoverflow.com as well about a day ago. No responses.
http://stackoverflow.com/questions/10544443/jquery-datatable-fnserverdata-error
I am attempting to load my jQuery Datatable via Ajax from an asp.net web service (.asmx) file.
I am using the following jQuery:
[code]
$("#taskTable").dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ajaxPages/getTheTasks.asmx/getAllTasks",
"fnServerData": function (sSource, aoData, fnCallback) {
alert("test");
aoData.push({ "name": "id", "value": ProjectID });
$.getJSON(sSource, aoData, function (json) {
fnCallback(json);
});
}
});
[/code]
I have been debugging with firebug. I can stop on each of the lines all the way down to "fnserverData". Once I hit that line, I can't step into the function. The alert never triggers. I never even get to send a request to the web service. It just skips over. I've rewritten this code several times and based it off of several different examples.
This code here is nearly verbatim from the datatables websites, which does work. (The datatables website example uses a PHP source. I even copied that source and tried to use that through the sAjaxSource but it still didn't step into the fnServerData.
In case anyone asks, my web service returns a string (serialized json). I can't imagine the web service being an issue here seeing as though the request never even gets sent.
If I put a break point on the $.getJSON line, it never hits. My debugger never outputs an error.
Thanks anyone for checking this out!
http://stackoverflow.com/questions/10544443/jquery-datatable-fnserverdata-error
I am attempting to load my jQuery Datatable via Ajax from an asp.net web service (.asmx) file.
I am using the following jQuery:
[code]
$("#taskTable").dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "ajaxPages/getTheTasks.asmx/getAllTasks",
"fnServerData": function (sSource, aoData, fnCallback) {
alert("test");
aoData.push({ "name": "id", "value": ProjectID });
$.getJSON(sSource, aoData, function (json) {
fnCallback(json);
});
}
});
[/code]
I have been debugging with firebug. I can stop on each of the lines all the way down to "fnserverData". Once I hit that line, I can't step into the function. The alert never triggers. I never even get to send a request to the web service. It just skips over. I've rewritten this code several times and based it off of several different examples.
This code here is nearly verbatim from the datatables websites, which does work. (The datatables website example uses a PHP source. I even copied that source and tried to use that through the sAjaxSource but it still didn't step into the fnServerData.
In case anyone asks, my web service returns a string (serialized json). I can't imagine the web service being an issue here seeing as though the request never even gets sent.
If I put a break point on the $.getJSON line, it never hits. My debugger never outputs an error.
Thanks anyone for checking this out!
This discussion has been closed.
Replies
One thing I would say is that I strongly suspect it will be a JSON error - your server likely isn't returning valid JSON and since there is no 'error' handling function it just disappears. I'd suggest using fnServerParams rather than fnServerData for just adding an extra parameter to the parameter list. Then we can use the debugger ( http://debug.datatables.net ) to get more of an idea of what might be going wrong.
Allan
Thanks for the consideration, Allan.