I have a jQuery/datatables app I’m writing, and I’m getting the following Firebug JS error:
TypeError: $("#my-datatable").datatable is not a function
[Break On This Error]
"fnServerParams" : function(serverParams) {
When I click the on the error it brings me to the following jQuery/datatbale code I wrote:
$("#my-datatable").datatable( {
"sAjaxSource" : "/widgets/doSomething",
"fnServerParams" : function(serverParams) {
serverParams.push(
{
"name" : "provider",
"value" : token
}
);
}
});
It’s complaining about the line that read:
“fnServerParams” : function(serverParams) {
How am I using this incorrectly?
Since the error is ‘$(“#my-datatable”).datatable is not a function’, this usually means the source code for the function has not been included. Are you including whatever source js files needed for this before calling the function?
If you are already including this, the other thing to check would be to make sure the call happens when the DOM is ready. This can be done with $(document).ready or $(function(){}) like so: