Я пытаюсь получить html-код по запросу ajax. Но я всегда получаю плохой запрос ajax 400. Есть и другие запросы, но они не создают никаких проблем.
Ниже мой код
jQuery(document).on('click', '.evecal-month-view-control', function(e){
e.preventDefault();
var month = jQuery(this).data('month');
var year = jQuery(this).data('year');
_getMonthCalendar(month, year);
});
var _getMonthCalendar = function(month, year){
jQuery.ajax({
type: 'post',
url: eventcaldata.ajaxurl,
data:{
action: 'ec_ajax_get_months_table',
month: month,
year: year,
nonce: eventcaldata.nonce,
},
beforeSend: function(){
},
success: function(response){
console.log(response);
}
});
}
Не знаю, в чем проблема. Все кажется нормальным
Вот код nonce
public static function adminassets(){
wp_enqueue_style( 'eventcal-admin-css', WP_EVECAL_CSS_URL . 'style-admin.css', array(), '1.0', 'all' );
wp_enqueue_style( 'pe7stroke.css', WP_EVECAL_FONTS_URL . 'pe-icon-7-stroke.css', array(), '1.0', 'all' );
wp_enqueue_script( 'eventcal-admin-js', WP_EVECAL_JS_URL . 'script-admin.js', array( 'jquery' ), '1.0', true );
$localize = array(
'ajaxurl' => admin_url('admin-ajax.php'),
'imagesurl' => WP_EVECAL_IMAGES_URL,
'nonce' => wp_create_nonce(WP_EVECAL_SLUG),
);
wp_localize_script( 'eventcal-admin-js', 'eventcaladmindata', $localize );
}