I am working on a code that utilizes JSON to validate VAT numbers.
My main goal is to identify which VAT numbers are valid
BTW[0] = 'NL1234567890';
BTW[1] = 'NL1233537891';
BTW[2] = 'NL1232346894';
var arraylength = BTW.length;
for (var i = 0; i < arraylength; i++) {
var BTWnummer = BTW[i];
callUrl = 'http://isvat.appspot.com/'+Land+'/'+BTWnummer+'/?callback=?';
$.getJSON(callUrl, BTWnummer, function(data){
alert(data+' '+BTWnummer);
});
}
The data variable provides a true or false response. However, I am facing a challenge in obtaining the correct BTWnummer within the JSON function. It seems to always retain one BTW number. I suspect that the JSON process is asynchronous, so I am seeking guidance on how to access the accurate number within the JSON code snippet. Based on my experimentation, it does utilize different numbers in the callUrl.