I have an array that look like this
var ids = ["id1","id2","id3","id4"]
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
I am familiar with PHP where I would use
foreach($array as $temporaryvariable){
// do stuff with $temporaryvariable
}
so I am looking for a Javascript or JQuery equivalent, so my final code will look something like the below
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);
}
}