Javascript 数据表杀死php中的其他脚本
我正在构建的php页面的头部包含以下脚本:Javascript 数据表杀死php中的其他脚本,javascript,php,scripting,datatables,Javascript,Php,Scripting,Datatables,我正在构建的php页面的头部包含以下脚本: <head> <!-- DataTables CSS --> <link href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css" type="text/css" rel="stylesheet"> <link href="//cdn.datatables.net/tabletools/2.2.0/css/dataTables.ta
<head>
<!-- DataTables CSS -->
<link href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css" type="text/css" rel="stylesheet">
<link href="//cdn.datatables.net/tabletools/2.2.0/css/dataTables.tableTools.css" type="text/css" rel="stylesheet">
<!-- jQuery -->
<script src="//code.jquery.com/jquery-1.11.1.min.js" language="javascript" type="text/javascript"></script>
<!-- DataTables -->
<script src="//cdn.datatables.net/1.10.5/js/jquery.dataTables.min.js" language="javascript" type="text/javascript"></script>
<script src="//cdn.datatables.net/tabletools/2.2.0/js/dataTables.tableTools.min.js" type="text/javascript" charset="utf-8" ></script>
<script class="init" type="text/javascript">
$(document).ready(function() {
$('#example').dataTable( {
"aLengthMenu": [[25, 50, 75, -1], [25, 50, 75, "All"]],
"iDisplayLength": 25,
dom: 'T<"clear">lfrtip',
tableTools: {
"aButtons": [ "csv", "xls", "pdf" ],
"sSwfPath": "//cdn.datatables.net/tabletools/2.2.0/swf/copy_csv_xls_pdf.swf"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://myIP/tools/ajax/snoozetable.php"
} );
} );
</script>
<script class="init" type="text/javascript">
$(document).ready(function() {
// Setup - add a text input to each footer cell
$('#example tfoot th').each( function () {
var title = $('#example thead th').eq( $(this).index() ).text();
$(this).html( '<input type="text" style="width: 40px;" placeholder="Search '+title+'" />' );
} );
// DataTable
var table = $('#example').DataTable();
// Apply the search
table.columns().eq( 0 ).each( function ( colIdx ) {
$( 'input', table.column( colIdx ).footer() ).on( 'keyup change', function () {
table
.column( colIdx )
.search( this.value )
.draw();
} );
} );
} );
</script>
<script type="text/javascript">
$(document).ready( function() {
$('#Location').autocomplete(
{source: function (request, response) {
$.ajax({url: "//localip/tools/ajax/locs_by_name.php",
dataType: 'jsonp',
data: {term: request.term},
success: response
})
},
minlength: 2,
select: function(event, ui) {
ui.item ? $('#locationid').val(ui.item.id) : $('#locationid').val('Error?');
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
})
});
</script>
</head>
$(文档).ready(函数(){
$('#示例')。数据表({
“阿伦提努”:[[25,50,75,-1],[25,50,75,“全部”],
“iDisplayLength”:25,
dom:'Tlfrtip',
表格工具:{
“阿布顿”:[“csv”、“xls”、“pdf”],
“sSwfPath”:“//cdn.datatables.net/tabletools/2.2.0/swf/copy\u csv\u xls\u pdf.swf”
},
“bProcessing”:正确,
“bServerSide”:正确,
“sAjaxSource”:http://myIP/tools/ajax/snoozetable.php"
} );
} );
$(文档).ready(函数(){
//设置-向每个页脚单元格添加文本输入
$('#示例tfoot th')。每个(函数(){
var title=$('#示例thead th').eq($(this.index()).text();
$(this.html(“”);
} );
//数据表
变量表=$(“#示例”).DataTable();
//应用搜索
table.columns().eq(0).each(函数(colIdx){
$('input',table.column(colIdx).footer()).on('keyup change',function(){
桌子
.列(colIdx)
.search(this.value)
.draw();
} );
} );
} );
$(文档).ready(函数(){
$(“#位置”)。自动完成(
{来源:函数(请求、响应){
$.ajax({url://localip/tools/ajax/locs_by_name.php“,
数据类型:“jsonp”,
数据:{term:request.term},
成功:回应
})
},
最小长度:2,
选择:功能(事件、用户界面){
ui.item?$('locationid').val(ui.item.id):$('locationid').val('Error?');
},
打开:函数(){
$(this).removeClass(“ui角点全部”).addClass(“ui角点顶部”);
},
关闭:函数(){
$(this.removeClass(“ui角顶部”).addClass(“ui角全部”);
}
})
});
如果删除所有其他脚本,$(“#Location').autocomplete脚本可以正常工作,但是对于所有datatable脚本,它不会执行自动完成,尽管datatable脚本都可以工作
有什么想法吗
请求的编辑:
<form method="post">
<dl class="formbody">
<table style="width:100%">
<tr>
<dt style="width: 200px;"><label for="Location">LocationName</label></dt>
<dd><input tabindex="5" id="Location" class="fld" name="Location" type="text" value="<?php echo $Location; ?>" /></dd>
</td>
</tr>
</table>
</form>
<table id="example" class="display" cellspacing="0" width="80%">
<thead>
<tr>
<th>SnoozeID</th>
<th>Side</th>
<th>BlockType</th>
<th>Partner</th>
<th>Pattern</th>
<th>Location</th>
..............
..............
..............
地点名称
很难模拟这里的内容,开发人员控制台会怎么说?(在webbrowser中按F12)。此外,你能显示你的实际表吗?我使用的是firebug,它没有显示最后一个脚本的错误或警告。location字段是表单的一部分,datatable位于表单下方:code
LocationName编辑您的问题并将表放在其中,而不是放在注释中。这里的问题是jquery的多个实例相互干扰。我可以通过用jQuery.noConflict()封装datatables脚本来解决这个问题;(函数($){…}