Everything happens on wordpress,
The request itself:
$(function(){ var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>'; $.ajax({ type: "POST", url: ajaxurl, data:{ action: 'weather_block' }, dataType: 'html', success: function(response){ $('.weather_block_page').html(response); console.log(response); }, error : function(jqXHR, textStatus, errorThrown) { $loader.html(jqXHR + " :: " + textStatus + " :: " + errorThrown); } }); });
And there is a file where the request comes in:
function weather_block_ajax_request(){ echo 'test'; die(); } add_action('wp_ajax_weather_block', 'weather_block_ajax_request'); add_action('wp_ajax_nopriv_weather_block', 'weather_block_ajax_request');
In the console, I get 0, why?
exit('abc')
- if in theabc
console, then everything is correct). If everything is good here, deal withadd_action
. So your function does not hang on these hooks or these hooks do not work. Where did you find such hooks? is there a link? - Ivan Pshenitsynexit('abc')
next to the code you give in php and you haveabc
output to the console - everything is fine with the request. Hooks do not work. Try others. - Ivan Pshenitsyn