Ajax进入wordpress

I would like to ask if where should the ajax url be pointed when I want to load a post through ajax get. I'm coming from a php framewor so basically there you just define ajax url using the routes that you have set. In wordpress how do you implement it. Here's my code so far:

$liquor = new WP_Query( array(
    'post_type'   => 'product',
    'posts_per_page'    => 10,
    'meta_query'  => array(
        array(
            'key'   => '_stock_status',
            'value' => 'instock',
        )
    ),
    'tax_query'             => array(
        array(
            'taxonomy'      => 'product_cat',
            'terms'         => $category['category_slug'],
            'field'         => 'slug',
            'operator' => 'IN'
        )
    )
) );

in your functions.php which is located in your theme add

function YourAjaxFunction() {
    //your code here
}

After that, add your hook with connects to the WP AJAX

add_action('wp_ajax_your_ajax_function', 'YourAjaxFunction');
add_action('wp_ajax_your_ajax_function', 'YourAjaxFunction');

wp_ajax_nopriv_%s allows it to be called from the front end.

And then, in your javascript file, you just fire off your ajax request.

$.post(ajaxurl, { action: 'your_ajax_function' }, function(output) {
alert(output);
});

source : How to add ajax to wordpress theme