Need some help with AJAX in WordPress. I'm encountering an issue where the response I get from AJAX is always showing as "0".
https://i.sstatic.net/9j4SM.png
function verifymsg()
{
var verifymobile = $('#verifymobile').val();
var otpmobile = $('#mobile').val();
alert(verifymobile);
alert(otpmobile);
var data = {
'action': 'verifyotp_ajax',
'verifymobile': verifymobile,'otpmobile': otpmobile
};
$.post(ajaxurl, data, function(response) {
alert(response);
$('#send').css("display", "none");
$('#verify').css("display", "block");
});
return false; }
Here's the specific code for WordPress:
add_action('wp_ajax_sendotp_ajax', 'sendotp_ajax_callback');
add_action('wp_ajax_nopriv_sendotp_ajax', 'sendotp_ajax_callback');
function sendotp_ajax_callback() {
$verifymobile=$_POST['verifymobile'];
$otpmobile=$_POST['otpmobile']
if($otpmobile=="success")
{
echo "success";
}}}