fnServerData - what to do if processing exception?
fnServerData - what to do if processing exception?
I have the following setup:
[code]
var dataTable = null;
$(document).ready(function() {
dataTable = $("#datatable").dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/RawData/List",
"fnServerData": function(url, data, callback) {
var tablename = $("#tablename").val();
if (tablename != "") {
if (data != null) {
data.push({ "datatable": tablename });
} else {
data = [{ "datatable": tablename}];
}
$.ajax({
"dataType": "json",
"type": "GET",
"url": url,
"data": data,
"success": callback
});
} else {
// what?
}
}
});
$("#tableselector").submit(function() {
dataTable.fnDraw();
return false;
});
});
[/code]
I get the server data on submit, adding the data needed to the url.
The only issue is that if tablename is blank, I get a "processing..." label that does not go away.
I tried returning false, following the standard idiom for events. I tried calling the callback function but it raises an error.
Aside from handling this outside fnServerData, is there anything that can be done within the function?
[code]
var dataTable = null;
$(document).ready(function() {
dataTable = $("#datatable").dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/RawData/List",
"fnServerData": function(url, data, callback) {
var tablename = $("#tablename").val();
if (tablename != "") {
if (data != null) {
data.push({ "datatable": tablename });
} else {
data = [{ "datatable": tablename}];
}
$.ajax({
"dataType": "json",
"type": "GET",
"url": url,
"data": data,
"success": callback
});
} else {
// what?
}
}
});
$("#tableselector").submit(function() {
dataTable.fnDraw();
return false;
});
});
[/code]
I get the server data on submit, adding the data needed to the url.
The only issue is that if tablename is blank, I get a "processing..." label that does not go away.
I tried returning false, following the standard idiom for events. I tried calling the callback function but it raises an error.
Aside from handling this outside fnServerData, is there anything that can be done within the function?
This discussion has been closed.
Replies
http://datatables.net/forums/comments.php?DiscussionID=1687&page=1
In any case, the OP's issue seems different than mine. My question is how do I indicate that the fnServerData has finished but with no processing?