All WordPress AJAX calls always return 0

admin2025-06-04  4

After page migration I have a problem with all AJAX calls. They always returning 0. I probably done everything and can't figure out what is wrong? Could you help me please?

Ajax call as shorten form:

$.ajax({
    url : '/wp-admin/admin-ajax.php',
    type : 'post',
    dataType: 'JSON',
    data : {
        action : 'ajax_newsletter',
        email : '[email protected]'
    },
    success : function( response ) {
        console.log(response);
    },
    error: function(err){
        console.log(err);
    }
});

Functions.php function as shorten form:

function ajax_newsletter() {
    $response = [];
    $resposne['succcess'] = true;
    wp_send_json($response);
    wp_die();
}
add_action('wp_ajax_ajax_newsletter', 'ajax_newsletter');
add_action('wp_ajax_nopriv_ajax_newsletter', 'ajax_newsletter');
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749022755a315699.html

最新回复(0)