Last active
May 10, 2016 11:50
-
-
Save SendOTP/bd37ad8403d0af1e2aa0 to your computer and use it in GitHub Desktop.
SendOTP Client Side sample code JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="jquery-2.1.4.min.js"></script> | |
<script type="text/javascript"> | |
function sendOTP() { | |
var data = {"countryCode": "country code", "mobileNumber": "Mobile number to be verified"}; | |
$.ajax({ | |
url: 'http://Your-domain-name/path/sendotp.php?action=generateOTP', | |
type: 'POST', | |
dataType: 'json', | |
data: data, | |
success: function(data){ | |
var resp = JSON.parse(response) | |
console.log(resp.status); | |
}, | |
error: function(jqXHR, textStatus, ex) { | |
console.log(textStatus + "," + ex + "," + jqXHR.responseText); | |
} | |
}); | |
} | |
function verifyOTP() { | |
var data = {"countryCode": "country code", "mobileNumber": "Mobile number to be verified","oneTimePassword":"One time password"}; | |
$.ajax({ | |
url: 'http://Your-domain-name/path/sendotp.php?action=verifyOTP', | |
type: 'POST', | |
dataType: 'json', | |
data: data, | |
success: function(data){ | |
var resp = JSON.parse(response) | |
console.log(resp.status); | |
}, | |
error: function(jqXHR, textStatus, ex) { | |
console.log(textStatus + "," + ex + "," + jqXHR.responseText); | |
} | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
success part of AJAX should be:
success: function(response){
console.log(response.message);
}