重新发布我的previous question因为我没有得到任何满意的答案
问题如下:
我已经在JSBin http://live.datatables.net/aqowib/2中提供了我的代码,因为我无法正确链接到sSwfPath。我在我的应用程序中使用codeiginter,所以我试图加载文件如下:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://<?php base_url(); ?>/assets/js/jquery.dataTables.js" type="text/javascript"></script>
<script src="http://<?php base_url(); ?>/js/jquery.dataTables.columnFilter.js" type="text/javascript"></script>
<script src="http://<?php base_url(); ?>/media/js/ZeroClipboard.js" type="text/javascript"></script>
<script src="http://<?php base_url(); ?>/media/js/TableTools.js" type="text/javascript"></script>
我的脚本标记包含以下代码:
$(document).ready(function(){
var oTable = $('#datatables').dataTable({
"sPaginationType":"full_numbers",
"sDom": 'Tlfrtip',
"oTableTools": {
"sSwfPath": "<?php base_url();?>/media/swf/copy_cvs_xls_pdf.swf"
},
"sScrollX": "100%",
"bScrollCollapse": true,
"bAutoWidth": true,
"aaSorting":[[0, "asc"]],
"bJQueryUI":true
}).columnFilter({
aoColumns: [ null,
null,
{ type: "select", values: [ 'male', 'female'] },
null,
null,
null,
null,
{ type: "select", values: [ '1', '2', '3', '4', '5', '6', '7','8','9','10'] },
{ type: "select", values: [ 'A', 'B', 'C'] },
null,
{ type: "select", values: ['P', 'A'] },
null,
null,
null
]
});
});
每次我收到404错误,说无法加载SWF文件时 - 请检查SWF路径
请帮我,我哪里错了? 提前谢谢。
答案 0 :(得分:1)
啊,得到了解决方案!
您只需在TableTools.js文件中配置sSwfPath URL,即
CHANGE TableTools初始化的默认设置
我走了:
TableTools.DEFAULTS = {
"sSwfPath": "http://localhost/codegen/media/swf/copy_cvs_xls_pdf.swf", <----------------- HERE IS WHERE I GOT STUCK
"sRowSelect": "none",
"fnPreRowSelect": null,
"fnRowSelected": null,
"fnRowDeselected": null,
"aButtons": [ "copy", "csv", "xls", "pdf", "print" ]
};
谢谢: - )
答案 1 :(得分:1)
无需写完整路径 只需在base_url之前放置echo :) 变化
<?php base_url();?>
要
<?php echo base_url();?>