Form ajax in frontend loses search values

I am using an ajax form in the frontend, and at the user experience level it is fabulous, the user can have fun finding what he wants by playing with the filters, no problem.

The problem instead arises when once the user decides to choose a result, he obviously enters the result page, but if he decides to go back to the search page, poof, search results disappeared, because there is no url from which fetching data the form does not keep the previous search in memory.

Structure of the ajax form:

<form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
<!-- form fields -->
<button>Apply filter</button>
<input type="hidden" name="action" value="myfilter">


<div id="response"></div>


add_action('wp_ajax_myfilter', 'ajax_filter_function'); // wp_ajax_{ACTION HERE}
add_action('wp_ajax_nopriv_myfilter', 'ajax_filter_function');

function ajax_filter_function(){
        $args =  array(
            'post_type' => 'pro',
            'posts_per_page' => -1,
            'meta_key'    => $_POST('categoryfilter'),
            'orderby'    => 'meta_value_num',
            'order'       => $_POST('order'),
    $query = new WP_Query( $args );

    if( $query->have_posts() ) :

        while( $query->have_posts() ): $query->the_post();


since the results are inside a single-nameofcustomposttype.php, obviously when the user selects the product he wants the url he follows the permalink of the custom post type, how to solve this huge problem?