helloxielan 2019-02-14 11:03 采纳率: 0%
浏览 97

列表中的未定义值

I'm a beginner in Ajax but a have a problem that I can't solved.

I'm trying to get the variable "label" in my list to compare it. i keep getting this error :

Uncaught TypeError: Cannot read property 'label' of undefined URL : http://localhost:8098/g2s/main/groupama/entreesParDomaine/entreesParDomaine.js?bust=1550141236956

Here is the comparison i'm trying to do :

JS File :

for (var k = 0; k < ucManager.listComponent.length; k++) {
    var nbEntreesReel = 0;
    //Boucle sur les issues de jira
    for (var j = 0; j < nbIssue; j++) {
        var listDomainIssue = ucManager.listIssue[j].domainList;
        var comptabilise = false;
        var no = true;
        var listLabelIssue = ucManager.listIssue[j].labelList;
        for (var l = 0; l < listDomainIssue.length; l++) {
           if (listDomainIssue[l].name == ucManager.listComponent[k].text) {
             comptabilise = true;
           }
        }
        for (var test = 0; listLabelIssue.length; test++) {
            if (listLabelIssue[test].label == "TGC1") {
               no = false;
            }
        }
}

The list : listIssue has 3 element inside : id, label and issuenum. So i'm trying to do the exact same loop that the listDomainIssue[l].name == ucManager.listComponent[k].text

But it doesn't work.

Hre is the Ajax part but I don't really know how to properly used it.

AJAx :

initJiraData : function() {
        $.ajax({
            type : 'GET',
            url : REST_PATH + 'groupama/jira/jiraDataGc',
            dataType : "json",
            async : false,
            contentType : 'application/json',
            success : function(data) {
                ucManager.listIssue = data.listIssue;
                var nbComponent = data.listComponent.length;
                for (i = 0; i < nbComponent; i++) {
                    var temp = new Object();
                    temp.id = i;
                    temp.text = data.listComponent[i].name;
                    ucManager.listComponent[i] = temp;

Hope you can help me.

  • 写回答

3条回答 默认 最新

  • weixin_33695082 2019-02-14 11:16
    关注

    On the fourth loop you have missed the <.

    It should be

    for (var test = 0; test < listLabelIssue.length; test++) {
            if (listLabelIssue[test].label == "TGC1") {
               no = false;
            }
        }
    

    Hope that helps.

    评论

报告相同问题?

悬赏问题

  • ¥50 深度学习运行代码直接中断
  • ¥15 关于#单片机#的问题,请各位专家解答!
  • ¥15 关于#单片机#的问题,请各位专家解答!
  • ¥20 需要完整的共散射点成像代码
  • ¥15 编写vba代码实现数据录入工作
  • ¥15 做过TCL海信电视小米电视相关影视会员软件私我
  • ¥15 Mapreduce是正常的,在运行其他jar包时并没有任何问题,只是在做LogCount.jar 时出的问题。如图所示
  • ¥15 ImportError: DLL load failed while importing _iterative: 找不到指定的模块。
  • ¥15 如何通过交互分析得出某高危患者对放疗获益更多
  • ¥15 相关性分析中,p<0.05, r=0.29,怎么评价相关性呢