I am using struts2 for my web application development. In a registration form there I want to use query ajax, so that the form gets submitted asynchronously and on a successful form submission I can get a server side success message in form of a toast or a element that comes and disappears.
Well for that I have tried a lot and somewhere achieved this thing but not using jquery ajax but normal javascript and ajax rather.
The flow of the code is as follows:
-
Home.jsppage with the form contained.<s:form theme="simple" action="registrationForDemo"> <table> <tbody> <tr> <td><s:label value="username" /></td> <td><s:textfield name="uName" cssClass="textfield" /></td> </tr> <tr> <td><s:label value="password" /></td> <td><s:password name="password" cssClass="textfield" /></td> </tr> <tr> <td><s:label value="email" /></td> <td><s:textfield name="email" cssClass="textfield" /></td> </tr> <tr> <td><s:label value="contact no." /></td> <td><s:textfield name="contactNo" cssClass="textfield" /></td> </tr> <tr> <td><s:label value="location" /></td> <td><s:textfield name="location" cssClass="textfield" /></td> </tr> <tr> <td><s:label value="category" /></td> <td><s:select list="{'Hospital','Doctor','Clinic','Others'}" name="category"/></td> </tr> <tr> <td></td> <td><s:submit value="Submit" cssClass="button" /></td> </tr> </tbody> </table> </s:form> -
The file where the mapping are defined i.e. struts.xml.

- When data is saved successfully in the database the output page is again the same page.
Now Using ajax and jquery I want to know how to achieve the required functionality. Where to pass the action from … and how to go further… ??
well for me the solution was
jquery.html()function. Where I passed the other html content to get the work done. Jquery htmlJquery is awesome and light weight too.