简体   繁体   English

jquery抛出太多递归异常

[英]too much recursion exception thrown by jquery

I am using fileupload using codeigniter and jquery ajax.我正在使用 codeigniter 和 jquery ajax 使用文件上传。 On saving other text and file, all things are saved however too much recursion error is thrown in console.在保存其他文本和文件时,所有内容都被保存,但是在控制台中抛出了太多的递归错误。 The code format to save is as follows:保存的代码格式如下:

doc_submitform = function(){
        var frm=$('#frm_save_doc').validate({
            errorElement: "small",
            wrapper: "div",
            debug : true,
            onclick : false,
            onblur  : true,
            focusCleanup: true,
            rules: {
                doc_type:{
                    required:true,
                },
                file_upload:{
                    required:true,
                },
                remarks:{
                    //required: true,
                }
            },

            highlight: function(label) {

                $(label).closest('.control-group').addClass('error');
            },
            submitHandler : function() {
                var file_data =$('#file_upload').prop('files')[0];

                var form_data = new FormData();
                form_data.append('file', file_data);
                form_data.append('doc_type', $('#doc_type').val())
                form_data.append('remarks',$('#remarks').val())
                form_data.append('emp_id', $('#emp_id').val())
                form_data.append('doc_id', $('#doc_id').val())

                $.ajax({
                        url: SITE_URL+'hrm/employee/ajax/action/save_doc_details',  
                        dataType: 'json',  
                        cache: false,
                        contentType: false,
                        processData: false,
                        data: form_data,                         
                        type: 'post',
                        success: function(response){
                            if(response.status == 200){
                                $docTable.fnDraw(false);                                
                            }

                            $('#frm_save_doc #cancel_btn').trigger('click');

                        }
                 });    

            }                           
        });
    },

Check that line:检查该行:

$('#frm_save_doc #cancel_btn').trigger('click');

#frm_save_doc #cancel_btn is not valid jQuery selector, if you want to specify any number of selectors, you should use: #frm_save_doc #cancel_btn不是有效的 jQuery 选择器,如果你想指定任意数量的选择器,你应该使用:

$( "#selector1, #selector2, #selectorN" );

Can you use just #cancel_btn instead?你可以只使用#cancel_btn吗? I think it should works.我认为它应该有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM