每次加载Datatables时都会收到此错误。任何人都知道为什么?
DataTables警告:table id = example - Ajax错误。更多 有关此错误的信息,请参阅http://datatables.net/tn/7
链接: http://cts360.ctscloudapp.com/simple.html
simple.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
<title>Editor example - Basic initialisation</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.14/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.3.1/css/buttons.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/select/1.2.2/css/select.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="/dataTables/css/editor.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="/dataTables/examples/resources/syntax/shCore.css">
<link rel="stylesheet" type="text/css" href="/dataTables/examples/resources/demo.css">
<style type="text/css" class="init"></style>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.12.4.js"> </script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.14/js/jquery.dataTables.min.js"> </script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/buttons/1.3.1/js/dataTables.buttons.min.js"> </script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/select/1.2.2/js/dataTables.select.min.js"> </script>
<script type="text/javascript" language="javascript" src="/dataTables/js/dataTables.editor.min.js"> </script>
<script type="text/javascript" language="javascript" src="/dataTables/examples/resources/syntax/shCore.js"> </script>
<script type="text/javascript" language="javascript" src="/dataTables/examples/resources/demo.js"> </script>
<script type="text/javascript" language="javascript" src="/dataTables/examples/resources/editor-demo.js"> </script>
<script type="text/javascript" language="javascript" class="init">
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "/queries/vendor.php",
table: "#example",
fields: [ {
label: "Company:",
name: "company"
}, {
label: "Brief Description:",
name: "briefDescription"
}, {
label: "Contact:",
name: "contact"
}, {
label: "Contact Title:",
name: "contactTitle"
}, {
label: "Work:",
name: "work"
}, {
label: "Mobile:",
name: "mobile"
}, {
label: "Email:",
name: "email"
}
]
} );
$('#example').DataTable( {
dom: "Bfrtip",
ajax: "/queries/vendor.php",
columns: [
{ data: "company" },
{ data: "briefDescription" },
{ data: "contact" },
{ data: "contactTitle" },
{ data: "work" },
{ data: "mobile" },
{ data: "email" }
],
select: true,
buttons: [
{ extend: "create", editor: editor },
{ extend: "edit", editor: editor },
{ extend: "remove", editor: editor }
]
} );
} );
</script>
</head>
<body class="dt-example">
<div class="container">
<section>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Company</th>
<th>Brief Description</th>
<th>Contact</th>
<th>Contact Title</th>
<th>Work</th>
<th>Mobile</th>
<th>Email</th>
</tr>
</thead>
</table>
</div>
</section>
</body>
</html>
vendor.php
<?php
/*
* Example PHP implementation used for the index.html example
*/
// DataTables PHP library
include( "../dataTables/php/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'vendors' )
->fields(
Field::inst( 'company' ),
Field::inst( 'briefDescription' ),
Field::inst( 'contact' ),
Field::inst( 'contactTitle' ),
Field::inst( 'work' ),
Field::inst( 'mobile' ),
Field::inst( 'email' )
)
)
->process( $_POST )
->json();