I am trying to get values posted by a form using ajax but i dont know how to get them. im opening a form which is also based on the ajax. here is the code.
the above code is just taking a url and displaying it into div. when im displaying a form using showPage('form. php'), the form is displayed correctly. im using the same function on the form action='showPag e('submit.php') and method='post' but this is not posting any data. please tell me wat im doing wrong and how i can get the posted data without defining any variables in the javascript. thanx
the form code is as follows:
Code:
function showPage(page)
{
var url=page;
//url=url+"?q="+page;
//url=url+"&sid="+Math.random();
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)
{
document.getElementById("container").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
the form code is as follows:
Code:
<div id="admForm">
<form name="form1" action="javascript:showPage('admission-form.php')" method="post">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" name="submit" value="Submit" />
</form>
</div>
Comment