Jump to content

Ajax Application Is Not Running


shobhit.singh783

Recommended Posts

I am trying below small ajax application from w3schools.org.According to this when I will open html file in browser then 2 text fields will appear and when We will enter name in Name text field then time wull automaticaly will apear in Time: text field.When I try this in IE 7.0 It does not work but when I try with firefox it work little bit but in place of time, all time.asp data appears in time field.As like-->Name: Shobhit Time: <% response.expires=-1 response.write(time) %>Expected Result-->Name: Shobhit Time: 7:48:22 AM testAjax.htm

<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","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>

time.asp

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

Pl post here your suggestions.Thanks,Shobhit

Link to comment
Share on other sites

It sounds like your server is not able to execute ASP code, or you are not accessing the page correctly. Make sure the URL of your page in the browser starts with "http://", if it starts with "file://" or anything else it's not going to execute the ASP code.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...