I am sending the code which is worked on browsers IE and Eclipse internal browser but not with mozilla. which is used to generate dynamic time on key stroke.
[HTML]<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("post","time.jsp");
xmlHttp.send("yjkyki");
}
</script>
<form name="myForm" >
Name: <input type="text" name="username" onkeyup="ajaxFunction();"/>
Time: <input type="text" width="150" name="time" />
</form>
</body>
</html>[/HTML]
test.jsp
Expand|Select|Wrap|Line Numbers
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <% java.util.Date d =new java.util.Date();
- %>
- <%=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds() %> -->
- <%System.out.println(d.toString());
- System.out.println("requested to server");%>