RyanStanford1
7 years agoQrew Captain
API_AddRecord from JavaScript Array creating duplicates
Hello,
I am using Javascript to pull out a row from one table, remove duplicates, and then I want to upload those results into another table, one record for each value.
Distinct is the array, and it has the proper values. The issue I'm having is that it appears to be that the for loop is going through the values twice, as when I'm expecting 2 rows, I'm getting 4.
Distinct.forEach(function(entry){
for(index = 0, len = Distinct.length; index < len; ++index){
var xhttp = new XMLHttpRequest();
xhttp.open('POST', "[REALM]/db/[DBID]?a=API_AddRecord&[TOKEN]&_fid_6="+Distinct[index],true);
xhttp.send();
}
})
I know that I'm probably overlooking something simple, like somehow closing the request, or trying to open it more than once...
I am using Javascript to pull out a row from one table, remove duplicates, and then I want to upload those results into another table, one record for each value.
Distinct is the array, and it has the proper values. The issue I'm having is that it appears to be that the for loop is going through the values twice, as when I'm expecting 2 rows, I'm getting 4.
Distinct.forEach(function(entry){
for(index = 0, len = Distinct.length; index < len; ++index){
var xhttp = new XMLHttpRequest();
xhttp.open('POST', "[REALM]/db/[DBID]?a=API_AddRecord&[TOKEN]&_fid_6="+Distinct[index],true);
xhttp.send();
}
})
I know that I'm probably overlooking something simple, like somehow closing the request, or trying to open it more than once...