I'm searching for an answer here for hours, and I can't find what's wrong with my code... my wordpress ajax keeps responding "0" no matter what I do... Here's the code:
header.php file:
wp_enqueue_script('js_'.$__page, NEVAL_ASSETS."js/js_course_{$__page}.js", array("jquery"));
js_course_all.js File:
var filter = jQuery("#input_filter").val()+"%";
var data = {
"action": "course_showall_refresh",
"data": {
"sort": _sorting.col,
"sort_dir": (_sorting.dir) ? 'asc':'desc',
"filter": filter
}
};
jQuery.post(ajaxurl, data, function(response){
alert(response);
});
view .php file:
function refresh(){
echo 'ajax_response';
die();
}
add_action("wp_ajax_course_showall_refresh", "refresh");
add_action("wp_ajax_nopriv_course_showall_refresh", "refresh");
The .JS is being correctly imported (the alert goes off with a "0" answer, other functions (UI functions) work correctly.