469,325 Members | 1,520 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

W3Schools Ajax time example doesn't work in my system

18
Hello,

This is an example from w3schools. I tried to execute this in my system, but it does not work.

My file is testajax.html

Expand|Select|Wrap|Line Numbers
  1. text
  2.  
  3. <html>
  4. <body>
  5.  
  6. <script type="text/javascript">
  7. function ajaxFunction()
  8. {
  9. var xmlHttp;
  10. try
  11.   {
  12.   // Firefox, Opera 8.0+, Safari
  13.   xmlHttp=new XMLHttpRequest();
  14.   }
  15. catch (e)
  16.   {
  17.   // Internet Explorer
  18.   try
  19.     {
  20.     xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  21.     }
  22.   catch (e)
  23.     {
  24.     try
  25.       {
  26.       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  27.       }
  28.     catch (e)
  29.       {
  30.       alert("Your browser does not support AJAX!");
  31.       return false;
  32.       }
  33.     }
  34.   }
  35.   xmlHttp.onreadystatechange=function()
  36.     {
  37.     if(xmlHttp.readyState==4)
  38.       {
  39.       document.myForm.time.value=xmlHttp.responseText;
  40.       }
  41.     }
  42.   xmlHttp.open("GET","time.asp",true);
  43.   xmlHttp.send(null);
  44.   }
  45. </script>
  46.  
  47. <form name="myForm">
  48. Name: <input type="text" onkeyup="ajaxFunction();" name="username" />
  49. Time: <input type="text" name="time" />
  50. </form>
  51.  
  52. </body>
  53. </html>
  54.  
  55.  

///////////////////////////////////////

another file time.asp

<%
response.expires=-1
response.write(time)
%>

//////////////////////////

I wrote exactly like this but it does not give time wehn I execute...

Please let me know what is the problem
Jun 20 '08 #1
3 3168
acoder
16,027 Expert Mod 8TB
Have you checked that the ASP file returns the correct output? Test by running the ASP file without using Ajax.
Jun 20 '08 #2
acoder
16,027 Expert Mod 8TB
I've split this from the other thread since it's a different problem.

I've deleted some useless posts that appeared under your name. Can you confirm if that was someone else posting?
Jun 20 '08 #3
dmjpro
2,476 2GB
@vpriya6
You are checking only readyState but not the statusCode as well.
Concentrate on Acoder's point.
See don't you get any updated value into your targeted Text Box(time)?
May 4 '09 #4

Post your reply

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

Similar topics

8 posts views Thread by needin4mation | last post: by
3 posts views Thread by Tony | last post: by
7 posts views Thread by Ivan Marsh | last post: by
31 posts views Thread by Tony | last post: by
25 posts views Thread by meltedown | last post: by
17 posts views Thread by Arjen | last post: by
6 posts views Thread by =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post: by
7 posts views Thread by Joe | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.