weixin_33716154 2015-10-26 13:52 采纳率: 0%
浏览 18

数据表AJAX需要警报

I am currently having a problem with the jQuery Datatables plugin. The browser (IE7) my website is made for is having trouble handing the AJAX request. When I take the alert() out, it doesn't load the Datatables values I get form my PHP (json).

When I leave it in, it gives me the alert, but it also fills the table. Does anyone know a way to check if the ajax request was handled properly, and then proceed to fill the table?

It does work this way in Chrome and FireFox, but for some reason it doesn't in IE.

So: My browser (IE7) doesn't wait for the AJAX call to be handled, when I do not have an alert under the script.

Any help would be appreciated!

$(document).ready(function(){
    $('#dataTables-example tfoot th.searchable').each( function () {
        var title = $('#example thead th').eq( $(this).index() ).text();
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );
    var data = $.get("/kleurmixer/hmi/view_json2.php?type=2", function(data){
        return data;
    });
    var table = $("#dataTables-example").DataTable(
            {
                "ajax" : {
                    "url" : "/kleurmixer/hmi/view_json2.php?type=2",
                    "dataSrc" : ''
                },
                "aoColumnDefs": [
                    { 'bSortable': false, 'aTargets': [ 7 ] },
                    { 'bSortable': false, 'aTargets': [ 8 ] }
                ]
            }
    );
    table.columns().every( function () {
    var that = this;

    $( 'input', this.footer() ).on( 'keyup change', function () {
        if ( that.search() !== this.value ) {
            that
                .search( this.value )
                .draw();
        }
    } );
    } );
    $(".dataTables_filter").html("");
    alert();
});
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制