This is my first attempt at coding AJAX and what should be simple isn’t. I’m using w3school’s example but I want to pass the form information to an ASP page then give a response based on the results. I’m wondering why my form values aren’t being passed to the ASP script.
<html>
<body>
<script type="text/javascript">
function ajaxFunction()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.myForm.time.value=xmlHttp.responseText;
}
}
xmlHttp.open("GET","ajax_respond.asp",true);
xmlHttp.send(null);
}
</script>
<form name="myForm" method ="post">
Name: <input type="text" name="name" />
Time: <input type="text" name="time" />
<input type="button" value = "submit" onclick="ajaxFunction();"/>
</form>
</body>
</html>
And for the validate script
<%
response.expires=-1
name = Request.Form("name")
if name <> "" then
response.write(time)
else
response.write "No name provided"
End if
%>
Now shouldn’t whatever is in my form be passed to the validation script? I don’t understand, I’m looking through tutorials and such but there isn’t a clear definition on how to pass a form value to the script.
Thanks for any help.