I have HTML form, and I want to send textarea entered values to jquery array and using for loop execute the ajax. my concern is I want to execute it one after one, once I got success to call back then it should increment. please my code below
    <form id="SendData" method="post">
      <textarea name="userids" id="DataArray" cols="10" rows="7"></textarea>
      <button type="submit" name="submit">submit</button>
   </form>
and my jQuery
<script>
$('#SendData').on('submit',function(e){
    e.preventDefault();
    var dataarray = $('#DataArray').val().split(",");
    for(var i=0; i<dataarray.length){
        $.ajax({
            type:'post',
            url:'reparepoola.php',
            data:{nuserid:dataarray[i]},
            success: function(result){
                if(result){
                    alert(result);
                    i++;
                    }else{
                        alert("end loop");
                        brake;
                        }
                }
            });
            }
    });
</script>
my loop is not working properly my only concern is that it should execute one after one. I tried setinterval but no use. I want to delay the loop for 1sec but its exciting in the middle of the loop. if I have more then 20 values in the array.
my reparepoola.php file is successfully sending back the results when I check with 2 values. more than that it's not working properly.
my reparepoola.php
include('dbhconfig.inc.php');
if($_POST){
         $newuserid = $_POST['nuserid'];
      $repare = $dbh->prepare("SELECT * FROM members WHERE userid='$newuserid'");
      $repare->execute();
        while($reparerow=$repare->fetch(PDO::FETCH_ASSOC)){
          $sponsor =$reparerow['sponsorid'];
          $todaydate=$reparerow['doj'];
          $userid = $reparerow['userid'];
          include('sponsorcomission.php');
          include('poola.php');
          echo $newuserid;  
         }
    }
