How to define variables in WordPress AJAX?

If you mean when you access you variables in JS code just by name they are really undefined in JavaScript environment. In order to access variables in JS you need to type as in your example
www_vars.whichcats
instead of just whichcats

Also it’s good to understand how wp_localize_script works.

First param is your js file handle previously declared with wp_enquee_script or wp_register_script (in your case it is wwww_loader). It says when it should be fired, because you really need these data for certain js file only, when it’s plugged in to particular page.

Second parameter is name of global variable which will store all your data passed in to JS via third argument – associative array of data.

It will create inline JS script when your script from handle will be included. And this inline JS will initialize these data in variable with name you’ve passed in as second parameter.

So first check if you’ve specified right script handle in first param. And check if you’ve queued this script before.
For example:

wp_enqueue_script(
'wwww_loader',
plugins_url( '/js/wwww_loader.js', __FILE__ ),
array( 'jquery' )
);

Then you can add needed data to it’s js execution context.

wp_localize_script('wwww_loader', 'wwww_vars', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'whichcats' => $whichcats,
'whichtags' => $whichtags,
'ajax_nonce' => wp_create_nonce('ww-ww-ww'), )
);

And finally you can check if you’ve really passed these data to JS
in a browser for example in Chrome open developer console hit F12 and in console type your variable name wwww_vars and press enter. If your script was properly linked you’ll see them as object in developer console output, otherwise it’ll show you undefined
If it’ll show you it’s value all is ok and you can reference in your JS file to these data like
wwww_vars.whichtags

EDIT:
Looks like you pass $whichtags and $whichcats variables to function but they are not previously defined in PHP. If so just initialize them before calling wp_localize_script with some default value, 0 or false or array() or ” emtpy string which one will describe your data in future when they’ll be filled in just before wp_localize script for example:


$whichtags="";
$whichcats="";
wp_localize_script('wwww_loader', 'wwww_vars', array(
'ajaxurl' => admin_url('admin-ajax.php'),
'whichcats' => $whichcats,
'whichtags' => $whichtags,
'ajax_nonce' => wp_create_nonce('ww-ww-ww'), )
);