SCRIPT5007:无法获取未定义或空引用的属性“ toLowerCase”

时间:2019-03-01 10:28:39

标签: javascript jquery

我在SharePoint上有一个.aspx文件。 我们正在使用IE11,jQuery 2.2.3,jQuery UI 1.11.4,Bootstrap 3.3.6 我们由第三方使用了该系统大约三年,我们停止了业务。而且无法联系了。

一切正常,直到几周前突然页面永久加载并显示此错误

  

SCRIPT5007:无法获取未定义或空引用的属性“ toLowerCase”

Loading page - capture

我已经使用Google搜索,似乎脚本正在等待加载ConfigurationCube.js。但是由于它没有加载,所以我认为它一直在等待。

/* handles the displaying of all outstanding items requiring approval*/
var TableCreated=0;
var app="";
var teamsArr = [];
var GlobalDivisionsArr = [];

$(document).ready(function(){

//check to see if the Configuration cube Obj Exists and wait until it does
var checkExist = setInterval(function() {       
   if (sessionStorage["ConfigurationCube"] != null) {         

        app = JSON.parse(sessionStorage.ConfigurationCube).AppURL;
        /**CreateLookupSectionForEmployees("My Winners","Kaizen List","#ViewWinnersTable");**/
        //Displayed using the configuration cube.js file
        DisplayUserInformation();
        popDD("kznSearchCategory",JSON.parse(sessionStorage.ConfigurationCube).ListOfCategories);
        IntialPopulationOfApprovedKaizens("","Kaizen List","#kznSearchResultsTable");


        //Initialize date range picker
        /**$("#kznEditToDate").datepicker();*/
        var CubeMin = (JSON.parse(sessionStorage.ConfigurationCube).SubmissionPeriod).split(" ")[0];            
        clearInterval(checkExist);  
    }

}, 500);

});

我也在IE8、9、10,Edge中尝试过。都无法正常工作。 我们公司不允许使用Chrome或任何其他浏览器,因此我们需要在IE中启用它。 我当前的meta标签就是这样。还尝试了各种方法,但是没有用。

<meta http-equiv="x-ua-compatible" content="IE=edge; charset=UTF-8">

有人有任何类似的问题吗? 任何想法都值得赞赏。.


单击错误时,它会定向到ConfigutationCube.js

//Tools for other pages

function compareStrings(a, b) {
// Assuming you want case-insensitive comparison
a = a.toLowerCase();
b = b.toLowerCase();                                                                
return (a < b) ? -1 : (a > b) ? 1 : 0;
}               

SearchKaizen.js中的脚本片段

function IntialPopulationOfApprovedKaizens(HeadingTitle,ListName,ElementToAppend){

//Get all current data from lists
var GetKaizenPromise = GetList( "Kaizen List",
                                "Id,Nominated_x0020_person, Status, Kaizen_x0020_Title,Division/Id, Team/Id,Division/Title, Team/Title, Name, Financial_x0020_Year, Kaizen_x0020_Category,Quarter",
                                "Division/Id, Team/Id,Division/Title, Team/Title",
                                "Status eq 'Approved'",
                                app);

$.when(GetKaizenPromise).done(function(KaizenSelectionData){

    var EditButton = "";    

    var Results = KaizenSelectionData.d.results;

    //Creates table structure and heading                      
    var DataTableHtml = "";
    var SetVotedBackground = "style='background-color:lightgreen;color:white;'";        

    var DivisionList = [];
    var TeamList = [];
    var YearList = [];

    var DivisionCheck = [];
    var TeamCheck = [];

    if(Results.length > 0){




        for(r=0;Results.length > r;r++){        

        TableCreated++;



        var ResultsName = Results[r].Nominated_x0020_person;
        var KaizenTitle = Results[r].Kaizen_x0020_Title;

        var ResultsTeam = Results[r].Team.Title;
        var ResultsDivision = Results[r].Division.Title;
        var ResultsTeamId = Results[r].Team.Id;
        var ResultsDivisionId = Results[r].Division.Id;


        var ResultsCategory = Results[r].Kaizen_x0020_Category;

        var ResultsStatus = Results[r].Status;
        var ResultsQuarter = Results[r].Quarter;
        var ResultsYear = Results[r].Financial_x0020_Year;


            EditButton = "<p style='cursor:pointer;' class='edititem text-light-blue' data-itemid='"+Results[r].Id+"' data-listname='"+ListName+"'><i class='fa fa-edit'></i> View</p>";        
            DataTableHtml += "<tr>"+
                            "<td>"+ResultsName+"</td><td>"+ResultsDivision+"</td><td>"+ResultsTeam +"</td>"+
                            "<td>"+ResultsYear+"</td><td>"+ResultsQuarter+"</td><td>"+KaizenTitle +"</td>"+
                            "<td>"+ResultsCategory +"</td><td>"+EditButton+"</td>"          
                          "</tr>";          

                //Create the drop down box info from all the results
                if($.inArray(ResultsDivision , DivisionCheck ) == -1){
                        // Add to departments list
                        DivisionList.push({"FullName": ResultsDivision,"ID":ResultsDivisionId});
                        DivisionCheck.push(ResultsDivision);    

                        //Keep duplicate of original divisions list
                        GlobalDivisionsArr.push({"FullName": ResultsDivision,"ID":ResultsDivisionId});
                }
                if($.inArray(ResultsTeam , TeamCheck) == -1){
                        // Add to Teams list
                        TeamList .push({"FullName": ResultsTeam,"ID":ResultsTeamId,"Division":ResultsDivisionId});  
                        TeamCheck.push(ResultsTeam);                

                        //Keep duplicates of original list
                        teamsArr.push({"FullName": ResultsTeam,"ID":ResultsTeamId,"Division":ResultsDivisionId});
                }
                if($.inArray(ResultsYear , YearList) == -1){
                        // Add to Year list
                        YearList.push(ResultsYear );                    
                }


            //next Item               
            }

        }else{
        //if there are no results       
            DataTableHtml = "<tr>"+
                                "<td colspan='8'>No results found</td>" +               
                              "</tr>";
        }   



        YearList.sort();
        YearList.reverse();

        TeamList.sort(function(a, b) {
          return compareStrings(a.FullName, b.FullName);
         });

        DivisionList.sort(function(a, b) {
         return compareStrings(a.FullName, b.FullName);
        });

        popDD("kznSearchYear",YearList);

        popDDSearchWithDataAttr("kznSearchTeam",TeamList,TeamList);

        DivisionList.unshift({"FullName": "All","ID":"All"});       //Add All option to division list
        popDDVal("kznSearchDivision",DivisionList);

           //adds items to DOM
        $(ElementToAppend + " tbody").html(DataTableHtml);              
        //Create column match with returned results         

        if (Results.length>0){
            $.fn.dataTable.ext.errMode = 'console';
            $(ElementToAppend).DataTable({  
                "dom": 'ftipr', 
                "responsive": true
            }); 
        }



    $("body").css("overflow","");

    //removes overlayer and loading symbol  
    $("#OverlayFade").addClass("hidden");
    $("#Timer").addClass("hidden"); 
});
}

此脚本片段具有popDDVal,并且看起来像'DivisionList''TeamList''YearList'返回null。由于此属性为null,因此无法脱离加载层。


我能够将其缩小到这一部分。

TeamList.sort(function(a, b) {
  return compareStrings(a.FullName, b.FullName);
});

DivisionList.sort(function(a, b) {
 return compareStrings(a.FullName, b.FullName);
});

将其更改为此,并且它起作用了。但是显然排序没有正确排序,但至少现在可以正常工作...

TeamList.sort();
DivisionList.sort();

1 个答案:

答案 0 :(得分:0)

不是传递匿名函数,而是传递函数名称:

TeamList.sort(compareStrings);

DivisionList.sort(compareStrings);