Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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
Javascript Jquery Datatable未从json文件读取ajax数据_Javascript_Jquery_Ajax_Json_Jquery Datatables - Fatal编程技术网

Javascript Jquery Datatable未从json文件读取ajax数据

Javascript Jquery Datatable未从json文件读取ajax数据,javascript,jquery,ajax,json,jquery-datatables,Javascript,Jquery,Ajax,Json,Jquery Datatables,我正在使用虚拟数据创建一些实体模型。我必须使用ajax在jQueryDataTable中显示一些数据,这些数据目前存储在一个.json文件中。我已经浏览了InDataTables站点,但是数据没有显示出来。可能是读取数据不正确或根本不正确。我已经尝试了很多解决方法,但似乎没有任何效果 文件夹结构如下所示: 我的HTML代码在backlog.HTML文件中。事情是这样的: <table id="backlogTable" class="grid"> <th

我正在使用虚拟数据创建一些实体模型。我必须使用ajax在jQueryDataTable中显示一些数据,这些数据目前存储在一个.json文件中。我已经浏览了InDataTables站点,但是数据没有显示出来。可能是读取数据不正确或根本不正确。我已经尝试了很多解决方法,但似乎没有任何效果

文件夹结构如下所示:

我的HTML代码在backlog.HTML文件中。事情是这样的:

<table id="backlogTable" class="grid">
            <thead>
                <tr>
                    <th nowrap="nowrap" width="230px">Hotel Name One</th>
                    <th nowrap="nowrap" width="110px">Hotel Price One</th>
                    <th nowrap="nowrap" width="230px">Hotel Name Two</th>
                    <th nowrap="nowrap" width="110px">Hotel Price Two</th>
                    <th nowrap="nowrap" width="230px">Hotel Name Three</th>
                    <th nowrap="nowrap" width="110px">Hotel Price Three</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
</table>
以下是LasVegas.json数据:


请提供帮助。

发生这种情况是因为它被视为跨域请求。尝试从localhost访问该文件,例如localhost/resources/LasVegas.jsonOk。所以现在使用localhost。Json数据正在响应,但现在,该表显示未找到任何记录。怎么了?@markpsmith,我用相同的目录结构复制了上面的代码,代码没有任何变化-它马上就可以工作了@明白了,你的代码在这里运行得很好。我已经使用dataTables 1.10.4进行了测试。您可能不是在像这样的服务器中运行代码http://localhost 文件将失败。所以这不是代码,而是如何运行它。@davidkonrad-我从语法上假设他使用的是v1.9。
XMLHttpRequest cannot load file:///Users/vshukla/Pictures/Mockups/html/resources/LasVegas.json. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource.
    {
  "aaData": [
                    [
                         "Wynn Las Vegas",
                         "$151",
                         "Caesers Las Vegas",
                         "$239.00",
                         "Flamingo Las Vegas",
                         "$151"
                    ],
                    [
                         "The Palazzo",
                         "$159",
                         "The Palazzo Resort Hotel Casino",
                         "$249.00",
                         "The Balazio Resort",
                         "$159"
                    ],
                    [
                         "Encore at Wynn Las Vegas",
                         "$151",
                         "Wynn Las Vegas",
                         "$359.00",
                         "Hotel Las Vegas",
                         "$151"
                    ],
                    [
                         "Caesars Palace",
                         "$229",
                         "Flamingo Bay",
                         "$219.00",
                         "Caesars Palace & Resort",
                         "$229"
                    ]
    ]
    }