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.

    评论

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格