Use value from Ajax call in PHP function

The main problem with what you’re attempting is that variables do not persist across requests. If you set a variable on the AJAX request, that variable will not be set on the request to reload the page.

The other problem is the way you’re referring to this as an “Example of function to change language”:

add_action('wp_loaded', 'my_icl_set_current_language'); 
function my_icl_set_current_language() {
    global $sitepress;
    $sitepress->switch_lang($dropdown_shop_order_language);
}

There’s 3 things here:

  1. A function, my_icl_set_current_language().
  2. The code inside the function that changes the language.
  3. A call to add_action() which tells WordPress when to run the function.

You only need #2, and you just need to put it inside your AJAX callback:

function my_action( ) {
    global $sitepress;
    $dropdown_shop_order_language = $_POST['dropdown_shop_order_language'];

    $sitepress->switch_lang($dropdown_shop_order_language);
}
add_action('wp_ajax_my_action', 'my_action');
add_action('wp_ajax_nopriv_my_action', 'my_action');