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.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?