【发布时间】:2017-07-17 12:27:18
【问题描述】:
我正在使用引导模板和 X 可编辑的内联编辑引导插件。
我有 2 列显示当用户选择更新该行中的列时更新该行的人员和时间。更新是通过内联编辑完成的。我希望它显示谁编辑了它而不刷新页面。但是,这些行仅由 php 脚本回显,因此这是不可能的。
所以在搜索后我发现了通过 javascript 调用外部 PHP 脚本。但是,该 javacsript 调用的结果似乎不适用于 css 和 js 链接。
所以我尝试复制 echo 上的 css 和 js 链接,可编辑的列现在可以工作,但布局完全混乱,所以我认为,问题在于,主页中链接的 css 和 js 是不适用于由 javascript 调用的 PHP 脚本回显的行。但我不知道如何解决这个问题。也许还有一些我还不知道的事情。
当整个 PHP 代码在主页面中时它可以工作
我的代码是这样的……
<html>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="css/uniform.css" />
<link rel="stylesheet" href="css/select2.css" />
<link rel="stylesheet" href="css/fullcalendar.css" />
<link rel="stylesheet" href="css/maruti-style.css" />
<link rel="stylesheet" href="css/maruti-media.css" class="skin-color" />
<link rel="stylesheet" type="text/css" href="css/z-mbcrs.css">
<!-- x-editable -->
<link href="bootstrap-editable/css/bootstrap-editable.css" rel="stylesheet"/>
<body>
<table class="table table-bordered data-table">
<thead>
<tr>
<td>ID</td>
<td>Column1</td>
<td>Column2</td>
</tr>
</thead>
<tbody id="table-data">
</tbody>
</table>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.ui.custom.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.uniform.js"></script>
<script src="js/select2.min.js"></script>
<script src="js/maruti.js"></script>
<script src="js/maruti.tables.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<script src="bootstrap-editable/js/bootstrap-editable.js"></script>
<script src="js/this-page-java.js"></script>
</body>
</html>
this-page-java.js的内容
$(document).ready(function(){
setInterval(function(){
$("#table-data").load("fetch-data.php");
}, 3000);
$.fn.editable.defaults.mode = 'inline';
$('.col1').editable({
type:'POST',
url:'post-data.php'
});
$('.col2').editable({
type:'POST',
url:'post-data.php'
});
});
获取数据.php
include "connection.php";
$select = mysqli_query($con, "SELECT * FROM table");
while($res = mysqli_fetch_assoc($select))
{
$id = $res['ID'];
$col1 = $res['Col1'];
$col2 = $res['Col2'];
echo"
<td>".$id."</td>
<td><a href='#' class='col1' data-name='Col1' data-type='text' data-pk='".$id."' data-url='post-data.php' data-title='Enter code'>".$col1."</a></td>
<td><a href='#' class='col2' data-name='Col2' data-type='text' data-pk='".$id."' data-url='post-data.php' data-title='Enter code'>".$col2."</a></td>
";
}
【问题讨论】:
标签: javascript php jquery twitter-bootstrap x-editable