Create JavaScript to handle OTP sending
unknown
plain_text
a month ago
1.2 kB
2
Indexable
Never
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.'); } } }); }); });
Leave a Comment