2

this is the first time that I see this error and I can't find a solution:

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})});

I can delete any row but I can only update the first one, the others(second and so on) return an error: TypeError: j is undefined and so I can't update the row with this code:

$(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});
    });

What am I doing wrong?

3
  • Typeerror in datatables usually means that the table html is invalid, where is your html for the table? Commented Aug 12, 2013 at 14:21
  • Now I delete the row and after I insert again the updated row, the table is simply the table tag with id and some classes Commented Aug 12, 2013 at 17:34
  • This can happen when you're missing the proper <tr> and <th> tags from the HTML. Commented Apr 7, 2015 at 17:29

1 Answer 1

1

If you get this kind of error in DataTable.js

TypeError: j[(f - d)] is undefined



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

always look for the

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

This is the actual count for each column that is used for displying your records

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

this is one block for one th

If you have 10th then please be sure you also have 10 above blocks

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.