The program I'm working on has an array with a bunch of web addresses in it, e.g:
var urls = ["http://www.url.com/page1", "http://www.url.com/page2", "http://www.url.com/page3"];
Then I loop through this array in order to run some code based on each web address:
for (var i = 0; i < urls.length; i++) {
$.get(urls[i], function(response) {
console.log(urls[i]);
});
I'm using the $.get to extract data from another page on the site, and my problem is that the console.log shows undefined? Even more strange is that if I pass url[1], or any value as a number into the console.log, then it returns the url from the array is intended?
Furthermore, if I just log the current for loop index like
console.log([i]);
then it just outputs 3, three times.