<!DOCTYPE html>
<html>
  <head>
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.1/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs5/jq-3.3.1/dt-1.10.25/sl-1.3.3/datatables.css"/>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.1/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs5/jq-3.3.1/dt-1.10.25/sl-1.3.3/datatables.js"></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>
        </tfoot>
        <tbody>
        </tbody>
      </table>
      <p style="color: red;">Display the Console and click 'Run with JS'.<br/><br/>The Console displays "Error: Script error. (line 0)"<br/><br/>
Note that the error.dt event does not fire.<br/><br/>
Note that the 'Processing...' box never goes away.</p>
    </div>
  </body>
</html>
 
body {
  font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  color: #333;
  background-color: #fff;
}
 
$(document).ready( function () {
      var table = $('#example')
      
      .on( 'error.dt', function (e, settings, techNote, message) {
         // This error event is never triggered 
        alert('An error has been reported by DataTables: ', message);
      })
          
      .DataTable({
        processing: true,
        serverSide: true,
        //ajax: "/ajax/objects.txt",
        ajax: function(data, callback, settings) {
            //
            // Simulate an SQL error on the server.
            //
            callback(
                { 'error': 'The SQL password is incorrect.' }
            );
            //
            // BUG 1:
            //
            // Instead of displaying the error response from the server,
            // DT triggers an uncaught exception in the console log
            // ('Error: Script error.')
            //
            // This is due to the following uncaught exception:
            //
            // jQuery.Deferred exception:
            // TypeError: Cannot read property 'length' of undefined
            // at _fnAjaxUpdateDraw (datatables.js:14539:27)
            // at datatables.js:14389:5
            // at callback datatables.js:14282:4
            //
            // BUG 2: The 'Processing...' box is never dismissed.
            //
        },
        columns: [
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "extn" },
            { "data": "start_date" },
            { "data": "salary" }
        ]
      });
    } )
1 error
Line 50: Missing semicolon.
Output 300px

This bin was created anonymously and its free preview time has expired. Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers