Hi,
In your action class you have to return null after you write the
response for eg:-
public String ajax() throws Exception {
respone.getWriter().println("hello");
respone.getWriter().close();
return null;
}
and also i dont think you need to specify the full URL when you are
doing the ajax call.,
Thanks,
Nuwan
animesh saxena wrote:
Hi,
I am using a very basic AJAX code snippet with struts. No it's not
dojo.
req = new XMLHttpRequest();
var url='http://localhost:8084/StrutsAjax/example/SearchAJAX.action';
req.open("POST",url,true);
req.onreadystatechange=searchResults;
req.send(null);
in searchResults() function I just wnt to see req.responseText;
If I want to return some response from server side if I use something
crude like this
response.getOutputStream().print("<html>Animesh</html>");
It messes up struts and I get lots of exceptions in responseText.
I want to return some string from the server side which is accessible by
javascript code. It can be JSON or anything.
What should be the code on server side / my action class (execute
method) to return something to client side? Any suggestions??
Thanks,
Animesh
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]