function response()
{
if (req.readyState==4)
{
if (req.status == 200)
{
var time = req.responseText;
alert(time);
document.getElementById("register").innerHTML = req.responseText;
}
}
}
</script>
</HEAD>
When I run this application, I can see that the request is being sent to the servlet (RegisterForm)
"System.out.println("inside doget");" is executed, "inside doget" is printed on to the Tomcat console but the response is not caught in the response() javascirpt method.
My guess is that you are never getting into that method and you probably have a javascript error (lower left hand corner of IE) when you try to run this.
At the very top of your response() method set an alert("Hi"); and see if you are even getting there.
Re: Simple ajax example using java - problem while receving the response from the ser
Hello Program This,
First off all, thanks for replying to my post. This is the first time I have ever used a forum. So I am sorry for posting it here.
I followed your suggestions. Modified the code as
req.onreadystatechange = function ()
{
if (req.readyState==4)
{
if (req.status == 200)
{
var time = req.responseText;
alert(time);
document.getElementById("register").innerHTML = req.responseText;
}
}
}
Bookmarks