Bryan Schmiedeler February 2016

HTML file using Jquery DataTables will load from file but not from IDE: $(...)DataTable is not a function error

I have a short test html file in which I include the Jquery Plugin DataTables. If I open the html file from the desktop into Chrome or Safari or another browser, it works. If however, I try to launch the file from within an IDE (like Xpages or Coda), I get the error $(...)DataTable is not a function.

I have included the Jquery library first, so I am baffled at to what the problem is.

The code is below:

<!DOCTYPE html>
<html>
  <head>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="https://nightly.datatables.net/js/jquery.dataTables.js"></script>
    <link href="https://nightly.datatables.net/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />


<script>
    body {
    font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    color: #333;
    background-color: #fff;
        }
</script>

<script>    
    $(document).ready( function () {
  var table = $('#example').DataTable();
} );



    </script>

    <meta charset=utf-8 />
    <title>DataTables - JS Bin</title>
  </head>
  <body>
    <div class="container">
      <table id="example" class="display nowrap" width="100%">
        <thead>
          <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        </thead>

        <tfoot>
          <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        &        

Answers


Spirit February 2016

Please try to remove your body style, first, because it has a wrong format. In your code sample:

<script>
    body {
    font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    color: #333;
    background-color: #fff;
        }
</script>

The second thing I see is a strange error message: "$(…)DataTable is not a function" there is no point symbol after $(…).

Post Status

Asked in February 2016
Viewed 3,998 times
Voted 11
Answered 1 times

Search




Leave an answer