0

Below is the peice of code in my project. The issue is that, whenever I'm calling function getLinks(), the ajax call gets the array data and printing only in "plots" div. The "graph" div is skipping out.

The ajax call is getting the data based on tabs correctly, but only issue is not printing in respective div.

Can please explain me what I'm missing here.. ??

getLinks() {

    var tabs = ['graph','plots'];
    var t = 0;

    for(t=0; t<tabs.length; t++) {

        var currentTab = tabs[t];
        var d = 0; var li = "";

        $.ajax({
            type: "post",
            url: 'url'+currentTab,
            success: function(data) {

                // 'data' will be group of array variable
                for(d=0; d<data.length; d++) { 

                    var id = data[d].id;
                    var label = data[d].label;

                    li = "<li><a href='/"+currentTab+"?product="+currentTab+"&id="+id+"'>"+label+"</a></li>";

                    $("#"+currentTab).append(li);
                }

            }
        });

    }
}

<div id="graph"></div>
<div id="plots"></div>
David
  • 539
  • 3
  • 9
  • 23
  • Have you checked to see if the url `'url'+'graph'` is actually returning something? – Toby Mellor Apr 27 '17 at 11:08
  • yes if I print the data varible inside success function, the data is returning properly of individual URL. Only not printing in respective div.. – David Apr 27 '17 at 11:13

0 Answers0