title: Use a FOR loop within an AJAX call
body: <p>So, what i'm trying to do is to send an AJAX request, but as you can see i have many fields in my form, and i use an array to make validations, i would like to use the same array, to pass the values to be sent via AJAX:</p>
  
  <p>I never used the for loop in JS, but seems familiar anyway.</p>
  
  <p>The way the loop is made, obviously wont work:</p>
  
  <pre><code>for (i=0;i&lt;required.length;i++) {
          var required[i] = $('#'+required[i]).attr('value');
  </code></pre>
  
  <p>This will create the variables i want, how to use them?</p>
  
  <p>HOPEFULLY, you guys can help me!!! Thank you very much!</p>
  
  <pre><code>required = ['nome','sobrenome','endereco','codigopostal','localidade','telemovel','email','codigopostal2','localidade2','endereco2','nif','entidade','codigopostal3','localidade3','endereco3','nserie','modelo'];              
  
  
  function ajaxrequest() {
      for (i = 0; i &lt; required.length; i++) {
          var required[i] = $('#' + required[i]).attr('value');
          var dataString = 'nome=' + required[0] + '&amp;sobrenome=' + required[1];
      }
      $.ajax({
          type: "POST",
          url: "ajaxload/como.php",
          data: dataString,
          success: function() {
              $(".agendarleft").html("SUCESS");
          }
      });
  </code></pre>