By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,187 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

Cannot call asp page

100+
P: 103
Hi all,

My html source is:
timeAj.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <script type="text/javascript">
Expand|Select|Wrap|Line Numbers
  1. function ajaxFunction()
  2.   {  var xmlHttp;
  3.   try
  4.     {   
  5.  // Firefox, Opera 8.0+, Safari    xmlHttp=new XMLHttpRequest();   
  6.  }
  7.   catch (e)
  8.     {   
  9.  // Internet Explorer  
  10.   try
  11.       {     
  12.  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
  13.     }
  14.     catch (e)
  15.       {     
  16.  try
  17.         {    
  18.     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");    
  19.     }
  20.  
  21.  catch (e)
  22.         {       
  23.  alert("Your browser does not support AJAX!");  
  24.       return false;        
  25.  
  26. }     
  27.  }   
  28.  }
  29.     xmlHttp.onreadystatechange=function()
  30.       {
  31.       if(xmlHttp.readyState==4)
  32.         {
  33.         document.myForm.time.value=xmlHttp.responseText;
  34.         }
  35.       }
  36.     xmlHttp.open("GET","time.asp",true);
  37.     xmlHttp.send(null); 
  38.  }
Expand|Select|Wrap|Line Numbers
  1. </script>
  2. <form name="myForm">
  3. Name: <input type="text"
  4. onkeyup="ajaxFunction();" name="username" />
  5. Time: <input type="text" name="time" />
  6. </form>
  7. </body>
  8. </html>
and asp page is:
time.asp
...........
Expand|Select|Wrap|Line Numbers
  1. <%
  2. response.expires=-1
  3. response.write(time)
  4. %>
  5.  
But i cant call.time.asp into the main page...

I am new in Ajax...

Please help me...

Regards,
Mathew
Oct 25 '07 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
If your code is as you have it typed here, look at the colours of the syntax highlighting. The XMLHttpRequest call has been commented out.

Remember to use code tags when posting code. As a full member, you should know that by now.
Oct 26 '07 #2

100+
P: 103
If your code is as you have it typed here, look at the colours of the syntax highlighting. The XMLHttpRequest call has been commented out.

Remember to use code tags when posting code. As a full member, you should know that by now.
HI,
I have changed the previous html code into the following..

timeAj.html
.................

[HTML]<html>
<body>
<script type="text/javascript">
[/HTML]
Expand|Select|Wrap|Line Numbers
  1. function ajaxFunction()
  2.  
  3. var xmlHttp;
  4.  
  5.   try
  6.  
  7.     {
  8.  
  9.     xmlHttp=new XMLHttpRequest(); 
  10.     }
  11.   catch (e)
  12.     {      
  13. try
  14.           {     
  15.  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");     
  16.      }
  17.     catch(e)
  18.         {     
  19. try
  20.         {        
  21.   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");       
  22.      }
  23.       catch(e)
  24.         {      
  25.   alert("Your browser does not support AJAX!"); 
  26.  
  27.     return false;
  28.  
  29.     }     
  30.       }    
  31. }
  32.     xmlHttp.onreadystatechange=function()
  33.       {
  34.       if(xmlHttp.readyState==4)
  35.         {
  36.         document.myForm.time.value=xmlHttp.responseText;
  37.         }
  38.       }
  39.     xmlHttp.open("GET","time.asp",true);
  40.     xmlHttp.send(null);  
  41. }
[HTML]</script>
<form name="myForm">
Name: <input type="text"
onkeyup="ajaxFunction();" name="username" />
Time: <input type="text" name="time" />
</form></body>
</html>
[/HTML]
when i enter some value in the first textbox ie,to the Name field,
the Time field displays '<%' .. I dont know how to display the current time..
Please help me...

Regards,
Mathew
Oct 26 '07 #3

100+
P: 103
hi,
I have written time.asp page in the notepad and save the file in the same folder where timeAj.html saved...

Please help me..

HI,
I have changed the previous html code into the following..

timeAj.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"
onkeyup="ajaxFunction();" name="username" />
Time: <input type="text" name="time" />
</form></body>
</html>

when i enter some value in the first textbox ie,to the Name field,
the Time field displays '<%' .. I dont know how to display the current time..
Please help me...

Regards,
Mathew
Oct 26 '07 #4

acoder
Expert Mod 15k+
P: 16,027
I don't want to remind you again. Use code tags when posting code.

Try running the ASP page without Ajax. Does that work?
Oct 29 '07 #5

Post your reply

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