title: Adding dynamic form data to ajax post request
body: <p>Say i have a form in html with the following content</p>
  
  <pre><code>&lt;form&gt;
      &lt;div id="si-main"&gt;
          &lt;button id="si-btn"&gt;Add new content&lt;/button&gt;
          &lt;div class="si-content"&gt;
              &lt;input type="text" class="si-input" name="content"&gt; 
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;input type="submit" id="si-submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Now i wanna append the ".si-content" div when i click the "#si-btn" i do that using this script in JS</p>
  
  <pre><code>$('#si-btn').click(function() {
      $('#si-main').append('&lt;div class="si-content"&gt;&lt;input type="text" class="si-input" name="content"&gt;&lt;/div&gt;')
  })
  </code></pre>
  
  <p>I then submit the form like this in JS </p>
  
  <pre><code>$('form #si-submit').click(function() {
      var data_to_send = {}
      $('form').find('.si-input').each(function() {
          if ($(this).hasClass('si-input')) {
              data_to_send[$(this).attr('name')] = $(this).val()      
          }
      })
      //NEXT I SEND THE AJAX REQUEST AND HANDLE THE RESPONSE
  })
  </code></pre>
  
  <p>Now the problem is each i append it adds a new "si-content" div. But when i send the data it only sends the content of the first div. Can someone tell me what would be the best way add the data in this case ?</p>