Jquery数据表:j未定义

时间:2013-08-08 17:28:15

标签: jquery datatables

这是我第一次看到这个错误而我找不到解决方案:

var request = $.ajax({
        type: "POST",
        url: "../php/admin_function.php",
        data: {
            act: "retrive_faq"
        },
        dataType: "json",
        success: function (a) {
            if ("ret" == a.response || "empty" == a.response) {
                if ("ret" == a.response) {
                    var b = a.faq.length;
                    for (i = 0; i < b; i++) {
                        a.faq[i].action = '<div class="btn-group"><button class="btn btn-info editdep" value="' + a.faq[i].id + '"><i class="icon-edit"></i></button><button class="btn btn-danger remdep" value="' + a.faq[i].id + '"><i class="icon-remove"></i></button></div>'
                    }
                }
                $("#loading").remove();
                $("#faqtable").dataTable({
                    sDom: "<<'span6'l><'span6'f>r>t<<'span6'i><'span6'p>>",
                    sWrapper: "dataTables_wrapper form-inline",
                    bProcessing: !0,
                    aaData: a.faq,
                    oLanguage: {sEmptyTable: "No FAQs"},
                    aoColumns: [
                        {sTitle: "Id",mDataProp: "id",sWidth: "60px"}, 
                        {sTitle: "Question",mDataProp: "question"}, 
                        {sTitle: "Postion",mDataProp: "position",sWidth: "50px"}, 
                        {sTitle: "Active",mDataProp: "active",sWidth: "60px"}, 
                        {sTitle: "Rate",mDataProp: "rate",sWidth: "40px"}, 
                        {sTitle: "Toogle",mDataProp: "action",bSortable: !1,bSearchable: !1,sWidth: "60px"}
                    ]
                });
            } else {
                noty({text: a[0],type: "error",timeout: 9E3})
            }
        }
    });
    request.fail(function (a, b) {noty({text: b,type: "error",timeout: 9E3})});

我可以删除任何行,但我只能更新第一行,其他行(第二行等)返回错误:TypeError: j is undefined所以我无法使用此代码更新行:

$(document).on('click','.submit_changes',function(){
        var dom=$(this).parent();
        var id= $("#faq_edit_id").val();
        var pos= $("#faq_edit_pos").val();
        var q= $("#edit_faq_question").val().replace(/\s+/g,' ');
        var p= $("#edit_faq_position").val();
        var ac= $("#activedep").val();
        alert(pos);
        <?php if(!$isMob) { ?>
            var a=CKEDITOR.instances.edit_faq_answer.getData().replace(/\s+/g," ");
        <?php }else { ?>
            var a=editora.getValue().replace(/\s+/g,' ');
        <?php } ?>
        if(q.replace(/\s+/g,'')!='' && a.replace(/\s+/g,'')!=''){
            var request= $.ajax({
                type: 'POST',
                url: '../php/admin_function.php',
                data: {act:'edit_faq',id:id,question:q,answer:a,active:ac,position:p},
                dataType : 'json',
                success : function (data){
                    if(data[0]=='Succeed'){
                        var action='<div class="btn-group"><button class="btn btn-info editdep" value="'+id+'"><i class="icon-edit"></i></button><button class="btn btn-danger remdep" value="'+id+'"><i class="icon-remove"></i></button></div>';
                        ac=(ac==1)? 'Yes':'No';
                        var mu={id:id,question:q,position:data[1],active:ac,rate:'Unrated',action:action};
                        $('#faqtable').dataTable().fnUpdate(mu,pos);
                        $('#faq_div').slideToggle(600);
                        $('#edit_faq').removeClass('open');
                    }
                    else
                        noty({text: data[0],type:'error',timeout:9000});
                }
            });
            request.fail(function(jqXHR, textStatus){noty({text: textStatus,type:'error',timeout:9000});});
        }
        else
            noty({text: 'Form Error - Empty Fields',type:'error',timeout:9000});
    });

我做错了什么?

1 个答案:

答案 0 :(得分:1)

如果您在 DataTable.js

中遇到此类错误
TypeError: j[(f - d)] is undefined



L(jQuery)})(window,document);

总是寻找

 "aoColumns": [{"bSortable": false, "mRender": checkbox}, {"mRender": fld}, null, null, null, {"mRender": row_status}, {"mRender": currencyFormat}, {"bSortable": false}],

这是用于记录记录的每列的实际计数

{"bSortable": false, "mRender": checkbox}

这是第一个

的一个块

如果你有10号,那么请确保你还有10块以上