A: 

You need to specify the correct url when calling the action. In your struts.xml file you would have created an action entry with a name. Let's say that name is VisitorCounterAction. Note that this is not the name of the Action class but the name you use in struts.xml.

Also you would have configured struts to recognize a particular extension. By default it is .do.

To request the action you will then use: VisitorCounterAction.do.

So try:

  xmlhttp.open("GET","VisitorCounterAction.do",false);

Note also the double quotes around the URL as this is a String in the xmlHttp object's open() method.

Vincent Ramdhanie
Hi,now the exception is this(Logger info in console):20:44:32,153 INFO [STDOUT] 2010-02-18 20:44:32,153 [http-localhost%2F127.0.0.1-8080-2] WARN com.liferay.portal.util.PortalImpl - Current URL /web/guest/VisitorCounterAction.do generates exception: null
Dj
A: 

The second parameter to the XMLHttpRequest object's open method should be a string that is the URL of the request. In your case it should be the Struts' Action Mapping that maps to your VisitorCounterAction. Something like:

xmlhttp.open("GET", "/viewCounterAction.do", false); 
John Topley
Hi John,My problem would be with my portal. I am using Liferay portal. it still gives the same exception. But i can see the alert msg at last.The exception is seen in console. I dono wat to do, it is not going to Action.
Dj
Can you please tell me which Jar should be included to make my application to have AJAX, I am using Struts 1.3 version.I have got struts2-dojo-plugin.jar, does that work for Struts 1.3 Version?
harigm
A: 

If you are using Liferay 4.2, then this link might help you (http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Ajax+Toolkit). Liferay 4.2 have own set of javascript API for doing AJAX functionality(Implemented in jquery).

Shashi Bhushan