Create JavaScript to handle OTP sending
unknown
plain_text
a year ago
1.2 kB
11
Indexable
jQuery(document).ready(function($) {
$('#send-otp-btn').on('click', function(e) {
e.preventDefault();
var phone = $('#phone').val();
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
action: 'send_otp',
phone: phone
},
success: function(response) {
if (response.success) {
alert('OTP sent successfully.');
} else {
alert('Failed to send OTP.');
}
}
});
});
$('#verify-otp-btn').on('click', function(e) {
e.preventDefault();
var otp = $('#otp').val();
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
action: 'verify_otp',
otp: otp
},
success: function(response) {
if (response.success) {
alert('OTP verified successfully.');
} else {
alert('Invalid OTP.');
}
}
});
});
});
Editor is loading...
Leave a Comment