title: javascript how to foreach loop through an array
body: <p>I have an array that look like this</p>
  
  <pre><code>var ids = ["id1","id2","id3","id4"]
  </code></pre>
  
  <p>I want to foreach loop through the array and extract each of the ids and pass that into ajax. so it will auto fill in some input field</p>
  
  <p>I am familiar with PHP where I would use </p>
  
  <pre><code>foreach($array as $temporaryvariable){
    // do stuff with $temporaryvariable
  }
  </code></pre>
  
  <p>so I am looking for a Javascript or JQuery equivalent, so my final code will look something like the below</p>
  
  <pre><code>var ids = ["id1","id2","id3","id4"]
  
  foreach(ids as id){
  $.ajax({
    url: "../folder/lookupserver.php",
    type: "POST", 
    data: {
      'id' : id//each of the ids
    },
    dataType: "JSON",
    success:function(data){
      $result= data;
      $('#input field').val($result);
    }
  }
  </code></pre>