I have xml file that contains the URLs for geocoding requests to Google. I want to iterate through the file, grab the URL (and later the site name...one step at a time), and send a Geocoding request to Google to get the lat and lng from the response. I am having problems with my $.ajax GET request. Can't the URL parameter just be a value in the array that contains my links? See my code below. Thank you for your help!
$(document).ready(
function() {
$locArray = new Array();
$coorsArray = new Array();
$.ajax({
type: 'GET',
url: 'data.xml',
dataType: 'xml',
success: function(d){
$(d).find('record').each(function(){
var $record = $(this);
var site = $record.find('site_name').text();
var $maplink = $record.find('maplink').text();
$locArray.push($maplink);
})
$($locArray).each(
function() {
$.ajax({
type: 'GET',
url: this,
dataType: 'xml',
success: function(d) {
$(d).find('location').each(function() {
var $location = $(this);
var $latcoor = $location.find('lat').text();
var $longcoor = $location.find('lng').text();
var $fullcoors = $latcoor + ", " + $longcoor;
console.log($latcoor);
$coorsArray.push($fullcoors);
//console.log($coorsArray);
})
$($coorsArray).each(
function(){
$('ul').append("<li>" + this + "</li>\n");
})
}
})
}
);
}
});
});