I want to redirect to the fastest URL after ajax
called all the URLs, but when I alert the value, I get undefined
:
var servers = ["url1", "url2", "url3"];
for (var i = 0; i < servers.length; i++) {
$.ajax({
type: "GET",
url: servers[i],
data: {},
cache: false,
success: function(output) {
// window.location.href = servers[i]
alert(servers[i]);
}
});
}