You’re sending a bad action for your AJAX request, the action should match with your string next to wp_ajax_
:
add_action('wp_ajax_fend_theme_data_save', 'fend_theme_data_save');
, so your action HTML field should be like this:
<input type="hidden" name="action" value="fend_theme_data_save" />
See the difference? Your action value should always be next to wp_ajax_
or wp_ajax_nopriv
, whatever you’re using. I recommend you to read AJAX in Plugins.
Also, if you’re using check_ajax_referer('fend-theme-data', 'security');
function, you should send the security
parameter within your jQuery data with its respective value, read more about this function; in this case will be something like this:
security=your-nonce-string
.
your-nonce-string means that you need to create a nonce named fend-theme-data
(the string that you’re comparing with check_ajax_referer() function) and send it using wp_localize_script()
function, read more about this function, and this one to create the nonce.
And, do not use die()
PHP function, use wp_die()
or wp_send_json_success
or wp_send_json_error
WordPress default functions.
I hope my answer helps you. 🙂