469,646 Members | 1,340 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Error in the ajax program

40
Hey Frnds..

I have made a program in which the user will enter the name and the time will automatically display in the other text box. But the problem it is not showing the output as needed. It is displaying the same text as written in the asp file.
Following the code.

[HTML]
<html>
<body>
<script type="text/javascript">

function ajaxFunction()
{
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
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","time.asp",true);
xmlHttp.send(null);
}
</script>

<form name="myForm">
Name: <input type="text" onkeydown="ajaxFunction();" name="username" />
Time: <input type="text" name="time" />
</form>
</body>
</html>[/HTML]

ASP file

Expand|Select|Wrap|Line Numbers
  1. <%
  2. response.write(time)
  3. %>
Jan 25 '07 #1
1 966
acoder
16,027 Expert Mod 8TB
Your AJAX is obviously working because it is obtaining the output from the ASP file, but you are getting the wrong output. I think that this is an ASP problem rather than an AJAX one. Have you tried running your ASP code without AJAX, i.e. by directly accessing time.asp in the browser?
Jan 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by melledge | last post: by
3 posts views Thread by =?Utf-8?B?bWNpbWFnaW5n?= | last post: by
2 posts views Thread by Mike P | last post: by
2 posts views Thread by germ | last post: by
2 posts views Thread by kpg | last post: by
9 posts views Thread by Trapulo | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.