I don't know what I am doing wrong.
var content = '';
$(document).ready(function() {
  $('a.main_group').click(function(){
    var t = $(this), gId = ('' + t.data('id')).split(',')[1];
    var div = $('li div.cbp-hrsub div.cbp-hrsub-inner');
    $.get(null, {__action: 'Get/Groups', groupId: gId, languageId: __lngId}, function (d){
      var obj = d.action.Object;
      $.each(obj, function(i, el){
        $.get(null, { __action: 'Get/Groups', groupId: el.Id, languageId: __lngId}, function (node){
          var obj2 = node.action.Object;
          $.each(obj2, function(i, el){
            content += "<div><h4>"+el.Title+"</h4>";
            content += "<ul>";
            $.get(null, {__action: 'Get/Groups', groupId: el.Id, languageId: __lngId}, function(node2){
              var obj3 = node2.action.Object;
              $.each(obj3, function(i, el){
                content += "<li><a href='"+el.Url +"'>"+el.Title+"</a></li>";
              });
            });
            content += "</ul></div>";
          });
        });
        content += "</div></div>";
        console.log(content);
      });
    });
  });
});
I need to generate HTML code with jQuery but I get only: <div></div>
If I change every assign content += '' to console.log, everything is fine. It
looks like the content variable is being initialized every time.
How can I fix this?
 
     
     
    