Wordpress when logged in as admin AJAX call returns 0
<p>When using WordPress <strong>as admin</strong> &amp; calling a WordPress function with AJAX I get <strong>"0"</strong>. But when <strong>logged out as admin</strong>, everything is <strong>working fine</strong>.  </p>

<p>Maybe anyone has gotten similar issues like mine and knows a possible fix?</p>

<p>I want that both logged in as admin, and logged out, would return the output (not 0 of course).</p>

<p>This is the function in <strong>functions.php</strong> file.</p>

<pre><code>add_action('wp_ajax_nopriv_get_category_data', 'getCategoryData');
add_action('wp_ajax_load_get_category_data', 'getCategoryData');

function getCategoryData()
{
    $data = [
    'category' =&gt; htmlspecialchars($_POST['category'])
];

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
    'post_type' =&gt; 'Coupons',
    'posts_per_page' =&gt; 8,
    'post_status' =&gt; 'publish',
    'paged' =&gt; $paged,
    'rewrite' =&gt; array( 'slug' =&gt; 'CustomCat' ),
    'caller_get_posts'=&gt; 1
);

$couponBlock = new WP_Query( $args );

if ($data['category']) {
    $the_query = new WP_Query(array ('cat' =&gt; $data['category'], 'posts_per_page' =&gt; 8) );
    if ($the_query-&gt;have_posts()):
        while ($the_query-&gt;have_posts()): $the_query-&gt;the_post();
            get_template_part('template/ajaxCustomCat', 'page');
        endwhile;
        wp_die();
    endif;

} else {
    return 'no data';
} 
}
</code></pre>