functions.php:
function rm_init_js() {
wp_enqueue_script( 'custom-ajax-script', get_template_directory_uri() . '/js/ajax.js', array( 'jquery', 'wp-util' ), '1.0', true );
// pass custom variables to JS
wp_localize_script( 'custom-ajax-script', 'BEJS', array(
'action' => ...