I want to use ajax within Struts to realize following function,there is a textfield an a submit button which use register a username in a JSP page,then you can put you name into textfield and click register button,then will call ajax to search name is exist,if exist,there will be a message behind textfield,say "name is exist,please use another name",like follows: --------------------------- Name:| | --------------------------- Register button
My code is follows,but my code can't reach my goal,I don't know how to realize it? Anybody could tell me how to do it? Thanks! <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <s:head theme="ajax"/> </head> <body> Name:<s:textfield id="data1" name="data1"/><div id="t1" style="display:none"></div> <img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/> <s:url id="ajaxTest" value="Test1.action" /> <s:submit type="submit" theme="ajax" value="submit" targets="t1" href="%{ajaxTest}" align="left" indicator="indicator"/> </body> </html>