I'm trying to create a code that will check a list of URLs if available or not but my problem is that it only returns the last link inside a loop.
below is my code:
$('#dlink').click(function(e) {
e.preventDefault();
var dcode = $('#dnum').text();
var dtemp = 0;
for(dtemp = 1; dtemp <= 10; dtemp++) {
var dlink = 'http://sample.com/export_template' + dtemp + '?field_delivery_code_value=' + dcode;
$.ajax(
{
type: 'GET',
cache: 'FALSE',
url: dlink,
success: function(response) {
window.open(dlink);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.debug("error for " + dtemp);
console.log(XMLHttpRequest);
}
});
}
});