hello,
I am trying to send values from one php page to another. I am getting the value in "ResponseText" , but when the next page is displayed , the value of the parameter specifically "fm" is not displayed on that php page.
Following is the code in "start.php" that I have written
<script language="javascript">
var httpObject=null;
function getXmlHttpObject(url,parameters)
{
try
{
// Firefox, Opera 8.0+, Safari
httpObject=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
httpObject=new ActiveXObject("Msxml2.XMLHTTP.4.0");
}
catch (e)
{
httpObject=new ActiveXObject("Microsoft.XMLHTTP");
}
}
if (httpObject != null)
{
httpObject.open("POST", url , true);
httpObject.onreadystatechange=function setOutput()
{
alert(httpObject.readyState);
if(httpObject.readyState == 4)
{
if (httpObject.status==200)
{
alert(httpObject.responseText);
}
}
}
httpObject.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
httpObject.setRequestHeader("Content-length", parameters.length);
httpObject.setRequestHeader("Connection", "close");
alert(parameters);
httpObject.send(parameters);
}
else
{
alert('Giving up Cannot create an XMLHTTP instance');
return false;
}
}
function ajax_check(obj)
{
var poststr="fm="+encodeURIComponent(document.getElementById("frommail").value)+"&cardto="+encodeURIComponent(document.getElementById("cardto").value)+"&greet="+encodeURIComponent(document.getElementById("greet").value)+"&mesg="+encodeURIComponent(document.getElementById("mesg").value)+"&send="+encodeURIComponent(document.getElementById("send").value)+"&Daycurrent="+encodeURIComponent(document.getElementById("Daycurrent").value)+"&Monthcurrent="+encodeURIComponent(document.getElementById("Monthcurrent").value)+"&Yearcurrent="+encodeURIComponent(document.getElementById("Yearcurrent").value)+"&previewbutt="+encodeURIComponent(document.getElementById("previewbutt").value)+"&tomail="+encodeURIComponent(document.getElementById("tomail").value)+"&Day="+encodeURIComponent(document.getElementById("Day").value)+"&Month="+encodeURIComponent(document.getElementById("Month").value)+"&Year="+encodeURIComponent(document.getElementById("Year").value);
getXmlHttpObject("privew.php",poststr);
</script>
<script language="javascript">
function chk_empty(form1)
{
var flag=0;
var cnt=0;
if(document.form1.send[1].checked=='true')
{
if((document.form1.Day.selectedIndex==0)||(document.form1.Month.selectedIndex==0)||(document.form1.Year.selectedIndex==0))
{
alert ("You have not selected the date.");
return false;
}
}
}
</script>
following is the coding of the form
<form name="form1" method="post" action="privew.php" onSubmit="return chk_empty(form1)" >
<input type=submit name=previewbutt value=Preview onClick="ajax_check(this.parentNode)" class="buttons">
</form>
what should I do so that I can get the value of parameter sent through AJAX
Thank you