jquery 我有一个mvc应用程序,在该数据是不是得到保存在数据库中,而点击保存按钮在铬或边缘,但它是在IE工作正常

kq0g1dla  于 2022-12-03  发布在  jQuery
关注(0)|答案(1)|浏览(95)

添加finalpartiallysave函数,其中uncaught是在控制台来相同的代码是在IE中工作,但在chrome,edge或火狐它是不工作的,数据是不getinenter代码在这里保存在数据库中请让我知道,如果需要任何东西,我困在它.附加下面的函数为参考我试图检查 AJAX 和aysnc,但它是不工作的

function FinalPartiallySave() {

            var separator = ";";
            var strPartiallyRows = "";

            var Error = "";
           

            var strSchemesRows = "";

            // New Schemes
            jQuery(".damage_new_scheme_row").each(function () {
                var SchemeName = $(this).find('.new_scheme_name').val();
                var Scheme = $(this).attr('scheme_id');
                var SchemeDenomination = $(this).find('.new_scheme_denomination').val();
                var SchemeQty = $(this).find('.new_scheme_qty').val();
                var Mapid = $(this).attr("mapid");

                Scheme = (Scheme == undefined) ? "" : Scheme;
                SchemeDenomination = (SchemeDenomination == undefined) ? "" : SchemeDenomination;
                SchemeQty = (SchemeQty == undefined) ? "" : SchemeQty;
                Mapid = (Mapid == undefined) ? "" : Mapid;

                if (SchemeQty == "0" || SchemeQty == "") {
                    Error += "Please enter Valid Qty for " + SchemeName + " Scheme \n";
                }
                else {
                    strSchemesRows = strSchemesRows +
                                    "" + separator +
                                    "" + separator +
                                    "" + separator +
                                    SchemeDenomination + separator +
                                    SchemeQty + separator +
                                    Mapid + separator +
                                    Scheme + ",";
                }
            });



            var dScheme = "";
            var ddl = document.getElementById("ContentPlaceHolder1_dc1_ddlscheme");
            for (var index = 0; index < ddl.all.length; index++) {
                if (ddl.all[index].selected) {
                    dScheme = ddl.all[index].text;
                    break;
                }
            }
            var dSchemeId = jQuery('#hd_scheme_id').val();

            var dSchemeDenomination = jQuery(".damage_new_scheme_row1").find('.new_scheme_denomination').val();
            var dSchemeQty = jQuery(".damage_new_scheme_row1").find('.new_scheme_qty').val();
            var dMapid = "0";

            dScheme = (dScheme == undefined) ? "Select" : dScheme;
            dSchemeDenomination = (dSchemeDenomination == undefined) ? "" : dSchemeDenomination;
            dSchemeQty = (dSchemeQty == undefined) ? "" : dSchemeQty;
            dMapid = (dMapid == undefined) ? "" : dMapid;

            if (dScheme == "Select" && (dSchemeDenomination != "0" || dSchemeQty != "")) {
                Error += "Please enter New Scheme Name\n";
            }
            if (dSchemeId == "-1" && (dSchemeDenomination != "0" || dSchemeQty != "")) {
                Error += "Please enter Valid New Scheme Name\n";
            }
            if (dSchemeDenomination == "0" && (dScheme != "Select" || dSchemeQty != "")) {
                Error += "Please select Coupon Type for " + dScheme + " Scheme\n";
            }
            if (dSchemeQty == "" && (dScheme != "Select" || dSchemeDenomination != "0")) {
                Error += "Please enter Qty for " + dScheme + " Scheme\n";
            }
            if (dSchemeQty == "0" && (dScheme != "Select" || dSchemeDenomination != "0" || dSchemeQty == "")) {
                Error += "Please enter Valid Qty for " + dScheme + " Scheme\n";
            }

            if (dScheme != "Select" && dSchemeDenomination != "0") {
                if (!FindDuplicateNewSchemeRows(dScheme, dSchemeDenomination)) {

                    strSchemesRows = strSchemesRows +
                                        "" + separator +
                                        "" + separator +
                                        "" + separator +
                                        dSchemeDenomination + separator +
                                        dSchemeQty + separator +
                                        dMapid + separator +
                                        dSchemeId + ",";
                }
                else {
                    Error += "Duplicate New Schemes Damage\n";
                }
            }
krcsximq

krcsximq1#

在检查了你的代码之后,我发现了一些不寻常的地方。这可能与不兼容问题有关。

var ddl = document.getElementById("ContentPlaceHolder1_dc1_ddlscheme");
    for (var index = 0; index < ddl.all.length; index++) {
        if (ddl.all[index].selected) {
            dScheme = ddl.all[index].text;
            break;
        }
    }

我们现在有了document.getElementById('id').all,也就是undefined。另外,all现在已经过时了,所以我建议尝试querySelectorAll

相关问题