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

列表中的未定义值

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.

    评论
  • from.. 2019-02-14 11:16
    关注

    somehow you used wrong syntax for loop
    please correct the loop for (var test = 0;test< listLabelIssue.length; test++)

    评论
  • 10.24 2019-02-14 11:21
    关注

    Please try changing the following line:

    for (var test = 0; listLabelIssue.length; test++) {
    

    with:

    for (var test = 0; test < listLabelIssue.length; test++) {
    

    the condition with listLabelIssue.length will always get true, if array is not empty. And also creates infinite loop.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#git#的问题,请各位专家解答!(相关搜索:开源项目)
  • ¥15 matlab处理脑电数据悬赏(时序图+预处理+频谱图)
  • ¥100 r语言多元回归模型怎么看表达式
  • ¥15 PMM 9010/30P
  • ¥15 pom文件依赖管理,未找到依赖
  • ¥15 现在后端返回给我一堆下载地址,都是一个视频切片后的,如何在uniapp安卓环境下将这些分片的视频下周并且合并成原始视频并下载到本地。
  • ¥15 Unity导出2D项目运行时图片变成马赛克
  • ¥15 关于communitytoolkit.mvvm的生成器得到的代码看起来没有被使用的问题
  • ¥15 matlab中此类型的变量不支持使用点进行索引
  • ¥15 咨询第六届工业互联网数据创新大赛原始数据