I have a function where I work through an array to go get distances for our locations. Upon return from that call I want to update the original Array with this new distance value. It is working in all browsers except IE (testing on IE11). It appears that the array is considered undefined.
Error: Unable to set property 'LocationDistance' of undefined or null reference
LocationsArr does exist, and I can pull/see values from it in the outer function, but not within the success: function of the $.ajax call.
Any help would be hugely appreciated!
function getLocationDistance() {
  let origin = UserLatitude + "," + UserLongitude
  let l = 0
  let distance = 0
  for (let i = 0; i < LocationsArr.length; i++) {
    let data = {
      ak: "XXXXXXXXXXXX",
      origin: origin,
      ID: LocationsArr[i].LocationID,
      destination: LocationsArr[i].LocationDestination
    };
    $.ajax({
      type: 'GET',
      url: "https://www.kaleidahealth.org/GoogleAPIServices/DistanceMatrix.svc/GetTripInfo",
      data: data,
      cache: false,
      dataType: "jsonp",
      success: function(result) {
        distance = result.distance.replace(" miles", "")
        // IE CAN'T SEE LocationsArr ARRAY - ALL OTHER BROWSERS CAN
        LocationsArr[i].LocationDistance = distance;
        l++;
        if (l === i) {
          buildLocationList();
        }
      },
      error: function(err) {
        alert("ERROR: " + JSON.stringify(err))
      }
    })
  }
}
 
    