Using data sent via AJAX in multiple functions on a WP plugin

As I understand your question, you want to Update a GF field with the results ($distance) of an AJAX request.

If that is correct, on a successful AJAX request, you just need to update the value of your GF field.

Assuming your response is the actual value correctly formatted. here’s what you need to do.

$.ajax({
  type: 'POST',
  url: url,
  data: {
    'action':'example_ajax_request',
    'distance' : distance
  },
  success:function(response) {
    // This outputs the result of the ajax request
    console.log(response);
    $('#your-GF-ID').val( response ); // This is where you update your GF field 
  },
  error: function(errorThrown){
    console.log(errorThrown);
  }
});