I have this code and I want to make the variable table a global variable but it doesn't work and I don't understand why, can someone help me?
      var table;
      function formatCustomerResults(obj) {
            var rows = Array();
            for (i = 0; i < obj.length; i++) {
                var item = obj[i];
                rows.push({
                    cell : [ item.guid, item.limittime, item.limitname ]
                });
            }
            console.log(rows);
            table = rows;
            return {
                total : obj.length,
                page : 1,
                rows : rows
            };
        }
        $.ajax({
            type : 'GET',
            url : 'http://localhost:6181/fintpWebServices/api/timelimits',
            dataType : 'json',
            success : function(data) {
                obj = data.timelimits;
                formatCustomerResults(obj);
            }
        });
         console.log(table);
 
     
     
     
     
    