i want to Click on the Submit That Send Otp to my Phone or Email im not Really Familiar With Ajax Can any one Explain how to do it on this Html :
<input type="submit" value="OTP code " name="Otp" id="Otp" autocomplete="off">
The easier way is to use jQuery.ajax
. If you aren't familiar with jQuery, jQuery is a JavaScript framework that makes JavaScript coding much easier and faster, especially for beginners.
More information about jQuery.ajax: jQuery.ajax() by jQuery.com
JavaScript Code:
$('#Opt').on('click', function(e){
e.preventDefault();
$.ajax({
url: 'target.php',
success: function(data){
//any code to handle "data" received from target.php
}
});
});
What we did in this example, is:
$('#Opt')
on('click', function...
e.PreventDefault()
$.ajax({...
url: 'target.php'
success: function(){...
In the success function you should add any code that you want to run as soon as the request is finished successfully. the data
var will contain the response from the server (in this case, the target.php
response).