Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
制表器Ajax示例在一台计算机上加载PHP错误,而不是在其他计算机上加载_Php_Ajax_Xampp_Tabulator - Fatal编程技术网

制表器Ajax示例在一台计算机上加载PHP错误,而不是在其他计算机上加载

制表器Ajax示例在一台计算机上加载PHP错误,而不是在其他计算机上加载,php,ajax,xampp,tabulator,Php,Ajax,Xampp,Tabulator,我试图让示例“使用AJAX加载数据”的源代码正常工作。我复制并粘贴了在此处找到的代码: 我安装了XAMPP3.2.4 它在我的另一台相同的计算机Windows 10 64位计算机上工作,但在当前这台计算机上,我遇到以下错误: tablator.min.js:6 Ajax加载错误-无效的JSON返回语法错误:JSON中位置0处的意外标记< (匿名)@tablator.min.js:6 tablator.min.js:6 Ajax加载错误:SyntaxError:JSON中位置0处的意外标记< (

我试图让示例“使用AJAX加载数据”的源代码正常工作。我复制并粘贴了在此处找到的代码:

我安装了XAMPP3.2.4

它在我的另一台相同的计算机Windows 10 64位计算机上工作,但在当前这台计算机上,我遇到以下错误:

tablator.min.js:6 Ajax加载错误-无效的JSON返回语法错误:JSON中位置0处的意外标记< (匿名)@tablator.min.js:6 tablator.min.js:6 Ajax加载错误:SyntaxError:JSON中位置0处的意外标记< (匿名)@tablator.min.js:6 tablator.min.js:6未捕获(承诺中)未定义

我完全不明白为什么会发生这种事

代码如下:

index.html

<html>
    <header>
        <link href="https://unpkg.com/tabulator-tables@4.8.4/dist/css/tabulator.min.css" rel="stylesheet">
        <script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.8.4/dist/js/tabulator.min.js"></script>
    </header>

    <body>
        <div>
            <button id="ajax-trigger">Load Data via AJAX</button>
        </div>
        
        <div id="example-table"></div>
    </body>

    <script>
        //Build Tabulator
        var table = new Tabulator("#example-table", {
            height:"311px",
            layout:"fitColumns",
            placeholder:"No Data Set",
            columns:[
                {title:"Name", field:"name", sorter:"string", width:200},
                {title:"Progress", field:"progress", sorter:"number", formatter:"progress"},
                {title:"Gender", field:"gender", sorter:"string"},
                {title:"Rating", field:"rating", formatter:"star", hozAlign:"center", width:100},
                {title:"Favourite Color", field:"col", sorter:"string"},
                {title:"Date Of Birth", field:"dob", sorter:"date", hozAlign:"center"},
                {title:"Driver", field:"car", hozAlign:"center", formatter:"tickCross", sorter:"boolean"},
            ],
        });
        
        //trigger AJAX load on "Load Data via AJAX" button click
        document.getElementById("ajax-trigger").addEventListener("click", function(){
            table.setData("load.php");
        });
        
    </script>
</html>

通过AJAX加载数据
//生成制表器
var table=新制表器(“示例表”{
高度:“311px”,
布局:“fitColumns”,
占位符:“无数据集”,
栏目:[
{标题:“名称”,字段:“名称”,分拣机:“字符串”,宽度:200},
{标题:“进度”,字段:“进度”,排序器:“编号”,格式化程序:“进度”},
{标题:“性别”,字段:“性别”,排序器:“字符串”},
{标题:“评级”,字段:“评级”,格式化程序:“星”,hozAlign:“中心”,宽度:100},
{标题:“最喜欢的颜色”,字段:“col”,分类器:“string”},
{标题:“出生日期”,字段:“dob”,分拣机:“日期”,hozAlign:“中心”},
{标题:“司机”,字段:“汽车”,hozAlign:“中心”,格式化程序:“滴答声”,分类器:“布尔”},
],
});
//点击“通过AJAX加载数据”按钮触发AJAX加载
document.getElementById(“ajax触发器”).addEventListener(“单击”,函数(){
table.setData(“load.php”);
});
load.php

<?php

//build data array
$data = [
    [id=>1, name=>"Billy Bob", progress=>"12", gender=>"male", height=>1, col=>"red", dob=>"", driver=>1],
    [id=>2, name=>"Mary May", progress=>"1", gender=>"female", height=>2, col=>"blue", dob=>"14/05/1982", driver=>true],
    [id=>3, name=>"Christine Lobowski", progress=>"42", height=>0, col=>"green", dob=>"22/05/1982", driver=>"true"],
    [id=>4, name=>"Brendon Philips", progress=>"125", gender=>"male", height=>1, col=>"orange", dob=>"01/08/1980"],
    [id=>5, name=>"Margret Marmajuke", progress=>"16", gender=>"female", height=>5, col=>"yellow", dob=>"31/01/1999"],
];

//return JSON formatted data
echo(json_encode($data));
?>

我已经卸载并重新安装了两次xampp。我不知道还能做什么。如果需要更多信息,请告诉我