微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

添加更多 65 列时数据表给出错误?

如何解决添加更多 65 列时数据表给出错误?

我在我的 mvc asp.net 应用程序中使用数据表,当我处理 65 列时,它工作得很好,但是当我再添加一列时,它给了我错误,即 DataTables 警告:table id=userTrackingList_table -阿贾克斯错误。有关此错误的详细信息,请参阅 http://datatables.net/tn/7. 在控制台上,错误消息是:加载资源失败:服务器响应状态为 400(错误请求)。

我的数据表代码: `
函数 GetUserTrackingListRecords() {

        userTracking = $('#userTrackingList_table').on('error.dt',function (e,settings,techNote,message) {
            console.log('An error has been reported by DataTables: ',message);
            console.log(e);
            console.log(settings);
            console.log(techNote);
            //HideMainDivOnLoggedOut();
        }).DataTable({

            "serverSide": true,"processing": true,"bPaginate": true,scrollY: "300px",scrollX: true,scrollCollapse: true,"ajax": {
                "url": '/Dashboards/GetUserTrackingData',"dataSrc": function (json) {
                    userTrackingData = json.data;
                    return json.data;
                },"data": function (d) {
                    return $.extend({},d,{
                        //companyCsv: Companies,userId: $("#ddlUser").val(),FromDate: $("#from_date").val(),ToDate: $("#to_date").val()
                    });
                }
            },"error": function (e) {
                $("body,html").animate({ scrollTop: 0 },'slow');
                showMessage(" " + e,"danger","","divMessage",true);
            },"dom": "<'row'<'col-sm-6'l><'col-sm-6'B>>" +
                "<'row'<'col-sm-12'tr>>" +
                "<'row'<'col-sm-5'i><'col-sm-7'p>>","columns": [

                { "title": "Id","data": "id","searchable": true,"visible": false,"orderable": false },{ "title": "From","data": "from","visible": true,{ "title": "To","data": "to",{ "title": "Deleted","data": "is_deleted","searchable": false,{ "title": "User Name","data": "username",{ "title": "Password","data": "password",{ "title": "Company Name","data": "company_name",{ "title": "Branch Name","data": "branch_name",{ "title": "Customer Level","data": "customer_level",{ "title": "Level Name","data": "level_name",{ "title": "City Name","data": "city_name",{ "title": "CC Email","data": "cc_email",{ "title": "POC Name","data": "poc_name",{ "title": "POC Mobile","data": "poc_mobile",{ "title": "POC Email","data": "poc_email",{ "title": "Salt Key","data": "saltkey",{ "title": "Hashing Data Pattern","data": "hashing_data_pattern",{ "title": "Hashing Data Pattern Description","data": "hashing_data_pattern_description",{ "title": "Master_merchant","data": "is_master_merchant",{ "title": "Random Key","data": "random_key",{ "title": "Nift Sub Merchant Id","data": "nift_sub_merchant_id",{ "title": "Nift Sub Merchant Password","data": "nift_sub_merchant_password",{ "title": "Alert Period Before Due Date","data": "alert_period_before_due_date",{ "title": "Alert Period Order Paid Summary","data": "alert_period_order_paid_summary",{ "title": "CSV Alert Period Days","data": "csv_alert_period_days",{ "title": "Failed Login Attempts","data": "Failed_login_attempts",{ "title": "Last Failed Login","data": "last_Failed_login",{ "title": "Block Days","data": "block_days",{ "title": "Penalty Type","data": "penalty_type",{ "title": "Upload Image Api Access Key","data": "upload_image_api_access_key",{ "title": "Threshold Value","data": "threshold_value",{ "title": "Number Of Partial Payments","data": "number_of_partial_payments",{ "title": "Due Dates Difference","data": "due_dates_difference",{ "title": "Email Feature","data": "email_feature",{ "title": "Sms Feature","data": "sms_feature",{ "title": "Sms Paid Order Alert Template","data": "sms_paid_order_alert_template",{ "title": "Email Subject Add Order Alert Template For Consumer Code","data": "email_subject_add_order_alert_template_for_consumer_code",{ "title": "Email Subject Add Order Alert Template For Connectpay Code","data": "email_subject_add_order_alert_template_for_connectpay_code",{ "title": "Sms Paid Order Alert To Merchant Template","data": "sms_paid_order_alert_to_merchant_template",{ "title": "Emailbody Add Order Alert Template For Connectpaycode","data": "emailbody_add_order_alert_template_for_connectpay_code",{ "title": "Sms Add Order Alert Template For Connectpay Code","data": "sms_add_order_alert_template_for_connectpay_code",{ "title": "Decimal Allowed","data": "is_decimal_allowed",{ "title": "Emailbody Alert Before Duedate Template For Consumercode","data": "emailbody_alert_before_duedate_template_for_consumercode",{ "title": "Emailbody Paid Order Alert Template To Merchant","data": "emailbody_paid_order_alert_template_to_merchant",{ "title": "Emailbody Paid Order Alert Template","data": "emailbody_paid_order_alert_template",{ "title": "Emailbody Add Order Alert Template For Consumercode","data": "emailbody_add_order_alert_template_for_consumer_code",{ "title": "Sms Content Alert Before Duedate Template For Connectpaycode","data": "sms_content_alert_before_duedate_template_for_connectpaycode",{ "title": "Sms Content Alert Before Duedate Template For Consumercode","data": "sms_content_alert_before_duedate_template_for_consumercode",{ "title": "Email Subject Alert Before Duedate Template","data": "email_subject_alert_before_duedate_template",{ "title": "Paid Email Alert To Merchant","data": "is_paid_email_alert_to_merchant",{ "title": "Paid Sms Alert To Merchant","data": "is_paid_sms_alert_to_merchant",{ "title": "Send Alert Before Duedate","data": "send_alert_before_due_date",{ "title": "Emailbody Alert Before Duedate Template For Connectpaycode","data": "emailbody_alert_before_duedate_template_for_connectpaycode",{ "title": "Sms Add Order Alert Template For Consumer Code","data": "sms_add_order_alert_template_for_consumer_code",{ "title": "Email Subject Paid Order Alert Template","data": "email_subject_paid_order_alert_template",{ "title": "Email Subject Paid Order Alert Template To Merchant","data": "email_subject_paid_order_alert_template_to_merchant",{ "title": "Blocked","data": "is_blocked",{ "title": "Logged in","data": "is_logged_in",{ "title": "Verified","data": "is_verified",{ "title": "Locked","data": "is_locked",{ "title": "Partial Payment Allowed","data": "is_partial_payment_allowed",{ "title": "Transaction By","data": "transaction_by",{ "title": "IP Address","data": "ip_address",{ "title": "Order Image required","data": "is_order_image_required",{ "title": "Penalty","data": "is_penalty",{ "title": "Self SignUp","data": "is_selfSignUp",],rowId: 'id',order: [[1,'desc']],"lengthMenu": [[10,25,50,100],[10,100]],buttons: [
                //{ extend: 'copy' },{
                    extend: 'excelHtml5',title: 'CompanyLogs' + new Date().getTime() + '',//exportOptions: {
                    //    columns: [3,4,5,6,7,8]
                    //}
                },{
                    extend: 'pdfHtml5',8]
                    //}
                }
            ]
        });

    }` 

这个函数调用区域是

 if ($.fn.dataTable.isDataTable("#userTrackingList_table")) {
            userTracking.draw();
        }
        else {
            GetUserTrackingListRecords();
            //   setTimeout(ChildTableInquiry(),6000);
        }

如您所见,我添加了 65 列,因为我在这里添加了 1 列,它会出错。我已经检查过我的后端完全没问题,只有当列数增加时它才会抛出上述错误

解决方法

我在我的 ajax 部分犯了错误,通过添加 "type" : "POST" 代码将运行良好。 由于 "type" ajax 请求没有默认定义 "GET" 请求正在工作,并且服务器拒绝了 get 请求。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。