jQuery DataTables Filter undefined is not a function

I am using php to generate a table, then jQuery DataTable to filter and sort my table:

function load_custumers_html(){

$sql_head = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'amitnet' AND TABLE_NAME = 'new_leads';";
$sql_body = "select * from new_leads;";

try {
    $db = getConnection1();
    $db1 = getConnection1();
    $stmt_head = $db->query($sql_head);
    $stmt_head1 = $db->query($sql_head);
    $stmt_head2 = $db->query($sql_head);
    $stmt_body = $db->query($sql_body);
    $colcount_head = $stmt_head->columnCount();
    $colcount_head1 = $stmt_head1->columnCount();
    $colcount_head2 = $stmt_head2->columnCount();
    $colcount_body = $stmt_body->columnCount();

    $data =  "<div style='clear: both;'></div>";
    $data .= "<table class='table table-striped table-hover table-condensed tablesorter tablesorter-header' id='new_customers'>";
    $data .= "    <thead>";

    $data .= "        <tr>";
    $J=0;
    while ($row = $stmt_head->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) {
        for ($i0=0; $i0 < $colcount_head; $i0++){
            $data .= "<th><select class='tselect$J' ></select><option value='0'> </option></th>";
            $J++;
        }
    }
    $data .= "        </tr>";

    $data .= "        <tr>";
    while ($row = $stmt_head1->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) {
        for ($ii=0; $ii < $colcount_head1 ;$ii++){
            $data .= "<th>$row[$ii]</th>";
        }
    }
    $data .= "        </tr>";
    $data .= "    </thead>";
    $data .= "    <tbody>";
    while ($row = $stmt_body->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) {
        $data .= "<tr>";
        for ($i=0; $i < $colcount_body; $i++){
            $data .= ($i == '0') ? "<td><a href='#/ncustomers/$row[$i]'>$row[$i]</a></td>" : "<td>$row[$i]</td>";
        }
        $data .= "</tr>";
    }
    $data .= "    </tbody>";
    $data .= "    <tfoot>";
    $data .= "        <tr>";
    $JJ=0;
    while ($row = $stmt_head2->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) {
        for ($ii=0; $ii < $colcount_head2 ;$ii++){
            $data .= ($JJ==0)? "<th>TEST</th>":"<th></th>";
            $JJ++;
        }
    }
    $data .= "        </tr>";
    $data .= "    </tfoot>";
    $data .= "</table>";
    $data .= "<script>$(document).ready(function() {
                var oTable =  $('#new_customers').DataTable({'language':{'url': 'db/Hebrew.json'},'Filter': true,'lengthMenu': [[10, 25, 50, -1], [10, 25, 50, 'הכל']],  'order': [[ 0, 'desc' ]],
                initComplete: function () {
                            var api = this.api();
                            api.columns().indexes().flatten().each( function ( i ) {
                                var tselect = '.tselect'+i;
                                var column = api.column( i );
                                $(tselect).append( '<option value=\"_\">_</option>' );
                                column.data().unique().sort().each( function ( d, j ) {
                                    if((i!=0)&&(i!=5)&&(i!=7)){
                                        $(tselect).append( '<option value=\"'+d+'\">'+d+'</option>' );
                                    }
                                });
                                $(tselect).change(function () {
                                    oTable.fnFilter('^'+$(this).val()+'$', i, false, false);
                                });
                            });
                        }
            });
            $('.table').on('click', 'tbody tr', function(event){ $(this).addClass('highlight').siblings().removeClass('highlight');});
            });</script>";
    echo $data;
    $db = null;
} catch (PDOException $e) {
    echo '{"error":{"text":' . $e->getMessage() . '}}';
}


}

Whenever I try to filter I keep getting an error of undefined is not a function referring to the following :

oTable.fnFilter('^'+$(this).val()+'$', i, false, false);

I am using this along side AngularJS, however I am not getting errors in my app, except for the fact that filter isn't firing.

Side note, I am using double rows for my table header, one displays the column titles pulled from the database and another showing the dynamically generated filters (select/dropdowns).

Any hope?

Any help is much appreciated.