I am using Javascript AJAX to send request a php page and receiving the output from php page. When I use GET
method in AJAX, its working. but the same is not working when i use POST
method.
here is my code:
<script>
function verifyMobile(mobileNo,code,emailKey)
{
alert(mobileNo+'-'+code+'-'+emailKey); //alerts proper value here...
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(xmlhttp.responseText); //alerts empty value here...
}
xmlhttp.open("POST","verification.php",true);
xmlhttp.send("mobileNo="+mobileNo+"&code="+code+"&emailKey="+emailKey);
}
</script>
verification.php
<?php
$mobile_number=trim($_POST['mobileNo']);
$sms_code=trim($_POST['code']);
$email_key=trim($_POST['emailKey']);
echo $mobile_number." - ".$sms_code." - ".$email_key;
?>