javascript - JavaScript - jQuery.Tabledit 不适用于特定的 url
问题描述
我试图将 jQuery.Tabledit ( https://markcell.github.io/jquery-tabledit/ ) 集成到我的表中。虽然它适用于一张桌子,但另一张桌子不起作用。经过大量试验,我在更改 url 时发现了一些奇怪的东西。
我的表的基本结构:
索引.php
<script type="text/javascript" src="tabledit.js"></script>
<table id="testing">
<thead>
<tr id="head">
<th>id</th>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr id="1">
<th>1</th>
<td>a</td>
<td>b</td>
</tr>
<tr id="2">
<th>2</th>
<td>c</td>
<td>d</td>
</tr>
</tbody>
</table>
<?php var_dump($_SESSION); ?>
tabledit.js
$(document).ready(function(){
$('#testing').Tabledit({
columns: {
identifier: [0, 'id'],
editable: [[1, 'Column 1'], [2, 'Column 2']]
},
onSuccess: function(data, textStatus, jqXHR) {
console.log('Success');
},
onFail: function(jqXHR, textStatus, errorThrown) {
console.log('Fail');
},
onAjax: function(action, serialize) {
console.log('onAjax');
console.log(action);
console.log(serialize);
},
hideIdentifier: false,
url: '../../database/test.php',
});
});
测试.php
<?php
session_start();
$_SESSION['test'] = 'heya';
?>
现在,如果我将文件test.php放在tabledit.js旁边并将 url 代码更改为
url: 'test.php',
,会话变量不会改变,这意味着test.php根本没有运行。
如果我把它放在tabledit.js上面的一个文件夹中(例如:project/table/tabledit.js和project/test.php)并将 url 代码更改为
url: '../test.php',
,它也不会工作。但是,如果我把它放在上面 2 个文件夹,像这样:
url: '../../test.php',
, 有用。同样的事情发生
url: '../../database/test.php',
我为此熬了一个通宵,但仍然不知道为什么。任何建议表示赞赏。
解决方案
推荐阅读
- spring - 在 Spring Boot 中查询超时不适用于 MS SQL 服务器
- r - Rmarkdown 将 echo 默认设置为 false 吗?
- javascript - 反转打字稿中的枚举
- powerbi - 如何通过 MAQ Software 从 Power BI 日历中删除时间戳?
- docker - 仅在 Chrome 上的 Windows 主机上缓慢的 docker HTTP 请求 chrome
- javascript - Vuejs - 事件总线(this.$root.$on)调用被重复
- android - 将 Android 内部日历与 Google 日历同步
- c++ - c++ 来自 2 个函数的多重继承,其中一个是纯虚函数
- python - 如何在 python 中解决这个错误(Jupyter notebook 中的代码)
- nginx - 如何获得类似于 google 在 NGINX 中返回的公共 IP 地址?