Php Ajax 500未能加载资源错误
每次加载数据表时都会出现此错误。有人知道为什么吗 DataTables警告:表id=示例-Ajax错误。更多 有关此错误的信息,请参阅 链接: simple.htmlPhp Ajax 500未能加载资源错误,php,ajax,datatables,Php,Ajax,Datatables,每次加载数据表时都会出现此错误。有人知道为什么吗 DataTables警告:表id=示例-Ajax错误。更多 有关此错误的信息,请参阅 链接: simple.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/fa
<!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>
编辑器示例-基本初始化
变量编辑器;//对于示例中的提交和返回数据呈现,请使用全局
$(文档).ready(函数(){
editor=new$.fn.dataTable.editor({
ajax:“/querys/vendor.php”,
表:“#示例”,
字段:[{
标签:“公司:”,
名称:“公司”
}, {
标签:“简要说明:”,
名称:“简要说明”
}, {
标签:“联系人:”,
姓名:“联系人”
}, {
标签:“联系人姓名:”,
姓名:“联系人姓名”
}, {
标签:“工作:”,
姓名:“工作”
}, {
标签:“移动:”,
名称:“手机”
}, {
标签:“电子邮件:”,
名称:“电子邮件”
}
]
} );
$('#示例')。数据表({
dom:“Bfrtip”,
ajax:“/querys/vendor.php”,
栏目:[
{数据:“公司”},
{数据:“简要说明”},
{数据:“联系”},
{数据:“contactTitle”},
{数据:“工作”},
{数据:“移动”},
{数据:“电子邮件”}
],
选择:true,
按钮:[
{扩展:“创建”,编辑器:editor},
{extend:“edit”,editor:editor},
{扩展:“删除”,编辑器:editor}
]
} );
} );
单位
简述
接触
联系人姓名
工作
可移动的
电子邮件
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();
出现500错误时,请查看服务器上的错误日志以了解详细信息。错误日志仅显示php错误。。AJAX是否还有其他错误?如果您使用AJAX调用PHP,这些都是正确的错误。请尝试指向供应商的绝对路径。php500表示在尝试处理AJAX调用时服务器上出现错误,因此您需要调试PHP。一般来说,它可以帮助您了解各种http状态代码的含义。你可以很容易地用谷歌搜索并找到一个列表