Site icon Hip-Hop Website Design and Development

Retailer ajax knowledge in PHP variable

I made an ajax name to get ID from the dropdown menu, I wish to get this knowledge retailer in variable PHP to make one thing

ajaxcalls.js

    $(".developer_select").on("change",perform(occasion){
        
        var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php';
        var nonce = jQuery('#wpestate_tab_stats').val();

        $.ajax({
            methodology: "POST",
            dataType: "json",
            url: ajaxurl,
            knowledge: {
                'motion': 'wpestate_load_get_developer_id',
                'developer_id': occasion.goal.worth,
                'safety': nonce
            },
            success: perform(knowledge){
                $(".res_developer_id").val(occasion.goal.worth);
                console.log(knowledge) // Output: {developer_id: 5} 5 for instance
            }
        })
        
    })

in capabilities.php

add_action( 'wp_ajax_wpestate_load_get_developer_id', 'wpestate_load_get_developer_id' );
add_action( 'wp_ajax_nopriv_wpestate_load_get_developer_id', 'wpestate_load_get_developer_id' );

perform wpestate_load_get_developer_id(){
    international $wpdb;
    $developer = intval($_POST["developer_id"]);

    $arr = array();
    $arr["developer_id"] = $developer;

    $json = json_encode( $arr );

    echo $json;

    $tab_terms      =   array();
    $phrases          =   get_terms( 'property_category', array(
                        'hide_empty' => false,
                    ) );
    
    foreach( $phrases as $single_term ){
        $args = array(
            'post_type'         =>  'estate_property',
            'creator'        =>   $developer,  // Right here I wish to get knowledge worth every choose
            'posts_per_page'    =>  -1,
            'post_status'       => 'publish',
            'meta_key'          => 'prop_featured',
            'orderby'           => 'meta_value',
            'order'             => 'DESC',
            'tax_query' => array(
                array(
                    'taxonomy' => 'property_category',
                    'subject'    => 'term_id',
                    'phrases'    => $single_term->term_id,
                ),
            ),
            'fields' => 'ids'
           );
          $all_posts = get_posts( $args );
           if( rely( $all_posts ) > 0 )
     $tab_terms[ $single_term->term_id ] = array( 'identify' => $single_term->identify, 'slug' => $single_term->slug, 'rely' => rely( $all_posts ) );

        }
       foreach($tab_terms as $time period){
        
            echo $time period['name']; // I wish to implement it in HTML div
        } 
    
    wp_die();
}