title: Add serial number to <tr> in ajax
body: <p>Iam using ajax to to dynamically generate table rows. I want to add serial number with every table row ie - td1. Everything else is working fine, please help me to add serial number with every tr.</p>
  
  <pre><code>&lt; script &gt;
      $(document).ready(function () {
          $('form').on('submit', function (e) {
              e.preventDefault();
              ajx();
          });
  
          function ajx() {
              $('tbody&gt;tr').remove();
              var side = $('input[name=pins]:checked').val();
              $.ajax({
                  beforeSend: function () {
                      $('#loader').show();
                  },
                  complete: function () {
                      $('#loader').hide();
                  },
                  url: "&lt;?php echo base_url('user/genealogy/ajaxLevels')?&gt;",
                  type: "POST",
                  dataType: 'json',
                  data: {
                      side: side
                  },
                  success: function (result)
                  {
  
                      var obj = jQuery.parseJSON(JSON.stringify(result));
                      var id = "#tbl";
                      $.each(obj, function () {
                          var row = $('&lt;tr&gt;');
                          var td1 = $('&lt;td /&gt;');
                          var td2 = $('&lt;td /&gt;');
                          var td3 = $('&lt;td /&gt;');
                          var td4 = $('&lt;td /&gt;');
                          var td5 = $('&lt;td /&gt;');
  
                          td1.text('1'); // I WANT TO ADD SERIAL NUMBER HERE
                          td2.text(this.name);
                          td3.text(this.id);
                          td4.text(this.date);
                          td5.text(this.sponsor_id);
  
                          row.append(td1);
                          row.append(td2);
                          row.append(td3);
                          row.append(td4);
                          row.append(td5);
  
                          $(id).append(row);
                      });
                  }
  
              });
          }
      });
  </code></pre>
  
  <p></p>
  
  <p>This is the table in which data is going to be shown :</p>
  
  <pre><code>&lt;table class="table"&gt;
      &lt;thead class="text-primary"&gt;
          &lt;th&gt;S.No.&lt;/th&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Member ID&lt;/th&gt;
          &lt;th&gt;DOJ&lt;/th&gt;
          &lt;th&gt;Sponser ID&lt;/th&gt;
      &lt;/thead&gt;
      &lt;tbody id="tbl"&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>