title: how to send dynamic data using ajax
body: <p>normally, we have a ajax request like:</p>
  
  <pre><code>$.ajax({
      type: 'GET',
      url: "/biboundsoptimization",
      data: {
          objects: '2',
      },
      success: function (data) {
          console.log(data);
          alert(data);
      },
      error: function (data, status, er) {
          alert("error: " + data + " status: " + status + " er:" + er);
      }
  });
  </code></pre>
  
  <p>but now I cannot know the number of variables in the data field . For example, when the client enters 2 the data field should be like: </p>
  
  <pre><code>data: {
      objects1: value of objects1,
      objects2: value of objects2,
  },
  </code></pre>
  
  <p>if the client enters 3 the data field should be like:</p>
  
  <pre><code>data: {
      objects1: value of objects1,
      objects2: value of objects2,
      objects3: value of objects3,
  },
  </code></pre>
  
  <p>Before the ajax request, the client has already entered the value of each objects into different input fields. But i don't know the number until he enters it. So i cannot write as above. it is obvious that a loop is required to get all the objects by looping over the number of loops provided by the client. I tried to something like:</p>
  
  <pre><code>for (int i = 1; i &lt; clientValue; i++) {
      'objects' + i: $('#objects' + i).val(),
  }
  </code></pre>
  
  <p>But it doesn't work. Grammatically it is wrong. Can anyone help me with that? Thanks!</p>