Forbidden Error in ajax call with wordpress

Question

I’m getting 403 error in my plugin develop when I try to use ajax calls. I had disabled all plugins and activated default theme, no works. I have no cache plugin, and I have no server cache.

I get:
403
Forbidden
Access to this resource on the server is denied!

PHP

add_action('wp_ajax_actualizar_jornada', 'actualizar_jornada' );
add_action('wp_ajax_nopriv_actualizar_jornada', 'actualizar_jornada');

    function actualizar_jornada() {
        $postdata = $_POST;
    
    
        echo $postdata;
    
        wp_die();
    }

LOCALIZATION SCRIPT

wp_register_script('lmfront-js', plugin_dir_url( __FILE__ ) . '../includes/js/lmfront.js');
wp_localize_script('lmfront-js', 'strings', array(
    'ajaxurl' => admin_url( 'admin-ajax.php' ),
    'lstJugadoresParticipantesPlaceholder' => __('Find Players', 'leaguemanagement'),
    'lstEquiposTeamsPlaceholder' => __('Find Teams', 'leaguemanagement'),
));
wp_enqueue_script('lmfront-js');

JS

$('.btn-update-jornada').on('click', function(){
    var idjornada = parseInt($(this).data('idjornada'));
    var data = {
        'action': 'actualizar_jornada',
        'idjornada': idjornada,
        'marcador_local': parseInt($('#resultado-local-' + idjornada).val()),
        'marcador_visitante': parseInt($('#resultado-visitante-' + idjornada).val()),
    };
    
    $.ajax({
       type : "post",
       url : strings.ajaxurl,
       data : data,
       error: function(response){
           console.error(response);
       },
       failure: function(response){
           console.error(response);
       },
       success: function(response) {
           console.log(response);
       }
   });
});
0
msolla 2 months 0 Answers 13 views 0

Leave an answer