is_single() conditional check inside ajax php function

is_single returns if there is a single page displayed within the actual server process. Within the Ajax-Function, nothing is “displayed”, you’re doing Ajax.

To check if the currently displayed object in your Browser is a single object, you need to transfer the information about this from the server process that serves your Browser to the server process that handles your ajax request.

Please try the following:
Step 1: get the information into your Javascript function. You get the information from the $wp_query object. If you directly echo the javascript which does the AJAX Request, you can do it like this:

<script>
var is_single = <?php echo (is_single() ? '1' : '0' ); ?>;
</script>

If you’re enqueueing your ajax-caller-script, you can use wp_localize_script .

Step 2: POST the is_single information to the Ajax Function

Step 3: check edit below! Change your Ajax PHP Function to incorporate the is_single information:

function rando_stuff(){

 $single = (int)$_POST['is_single'];
    if($single){
       //do stuff
    }
}

Step 4: Profit 😉

============================================
EDIT 2022-02-20:

5 Years ago, this was how i coded. However, since then i learned a bit more about proper working with POST values, so i rewrote the Function for step 3.
For Explanation: Values transmitted per POST or GET don’t have data types, so they are interpreted as strings. To use these Values as Boolean (true/false) data types, we have to typecast them. Luckily, WordPress has a function to properly interpret this.

function rando_stuff_improved(){
     $is_single = false;
     if( isset( $_POST['is_single'] ) ){
        $is_single = rest_sanitize_boolean( $_POST['is_single'] );
     }
     if( $is_single ){
        //do stuff
     }
   }