I'm able to retrieve data from the database but I'm having trouble using the returned variable. At the bottom of the code example I inserted DISPLAY JAVASCRIPT VAR region here??? where I need to use the region variable. How can I change my code to do that? Here's my code:


Code JavaScript:
     function handlePosition(pos)
{ $.ajax({                                      
      url: 'map.php',
      data: "lat=" + pos.coords.latitude + "&lon=" + pos.coords.longitude,
      dataType: 'json',
      success: function(data)
      { region = data[0]; } 
    });
} 
      </script>
      <select id="cities" multiple="multiple" name="cities[]" title="Confirm Your Deal Location"  multiple="multiple" data-native-menu="false">
      <?php $sql = "SELECT DISTINCT name, id
FROM `db` WHERE id != '1' ORDER BY name
";
  $sql_result = mysql_query($sql) or die(sprintf("Couldn't execute query, %s: %s", db_errno(), db_error()));
while ($row = mysql_fetch_array($sql_result)) {
 $mailregion = $row['name'];
 $group_id = $row['id']; ?>
      <option value="<?php echo "$group_id"; ?>" <?php if (($mailregion == 'Internet') || ($mailregion == DISPLAY JAVASCRIPT VAR region here???)) { echo "selected=\"selected\""; } ?>><?php echo "$mailregion"; ?></option>

Thanks in advance,

Tim