How to get current post ID in functions.php

Try to get the post_id from the POST values instead of the global $post.

function getcity(){
    global $wpdb;
    if($_POST['state']) {
        $id=$_POST['state'];
        $postid = $_POST['post_id'];
        $district = esc_html(get_post_meta($postid , 'district ', true));
        $result=$wpdb->get_results("SELECT * FROM districts WHERE state_id='$id'");
        foreach($result as $row) {
            $district_name=$row->district_name;
            $district_id= $row->district_id;
            ?><option value="<?php echo $district_id; ?>" <?php if($district == $district_id){echo 'selected="selected"';} ?>>
                <?php echo $district_name; ?>
            </option><?php
        }
    }
}
add_action("wp_ajax_nopriv_getcity", "getcity");
add_action("wp_ajax_getcity", "getcity");

<div class="container">
    <select name="state" id="state" class="select-submit2">
        <option value="">Select state</option>
        <?php
        $property_state = get_post_meta( $edit_id, 'state', true );
        $result         = $wpdb->get_results( "select * from states" );
        foreach ( $result as $row ) {
            $state_id   = $row->state_id;
            $state_name = $row->state_name;
            ?>
            <option value="<?php echo $state_id; ?>" <?php if ( $property_state == $state_id ) {
                echo
                'selected="selected"';
            } ?>><?php echo $state_name; ?></option>
        <?php
        }
        ?>
    </select>
    <input type="hidden" name="post_id" value="<?php echo $edit_id; ?>" class="post_id" />
</div>



$('#state').on('change', function() {

  var state  = $('#state').val();
  var post_id = $(this).siblings('.post_id').val();

  $.ajax
  ({
    type : "POST",
    url  : "http://plotsup.com/plotsup_plot/wp-admin/admin-ajax.php",
    data :{'action' : 'getcity', 'state' : state, 'post_id': post_id},
    success: function(html) {

      $("#district").removeAttr("disabled");
      $("#district").html(html);
    }

  });
 });

tech