Wordpress ajax very slow and can't retrieve post data

admin

Administrator
Staff member
I'm doing a simple wordpress ajax but the response is very slow and I can't retrieve the data. Here's my code

<strong>JS</strong>

Code:
function getProductData(idObj) {
    $.post('/wp-admin/admin-ajax.php', {'action':'get_product_data','data':'asdasd'}, function(response) {
        console.log(response);
    });
}

<strong>PHP</strong>

Code:
function get_product_data() {
    echo $_POST['data'];
}
add_action('wp_ajax_get_product_data', 'get_product_data');
add_action('wp_ajax_nopriv_get_product_data', 'get_product_data');

The response is always 0 and it takes 12 seconds to respond.