• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 hello world using AJAX Jquery is working but renders html input tags twice.

 
Monica Shiralkar
Ranch Hand
Posts: 825
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to run a simple Hello world of struts2 to learn its usage with AJAX Jquery.

What I am trying to accomplish: There is a text box to enter name and a submit button saying sayHello. On clicking this button if name entered is Mark it should display Hello Mark using AJAX. Below is my code which gives desired output but displays html content twice.. Please let me know if my below approach is correct or wrong:

The code is working but the the problem is On entering name as Mark it is showing Hello Mark (which is correct) but along with this it is rendering the text boxes one more time.

Struts.xml



here is my action class:



here is my JSP page where there is some mistake which renders HTML twice.




Also I was not sure whether to post this in Struts forum or JSP forum or CSS,AJAX,Jquery Javacript Forum.

thanks

 
Karthik Jayachandran
Ranch Hand
Posts: 91
Android AngularJS Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Might be the jsp page mentioned in result tag is loading again and again.

Try using json method - refer Struts2 Json plugin

or get a workaround - refer Returning string in struts 2
 
Harikrishna Gorrepati
Ranch Hand
Posts: 423
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I copied your code and ran. I have changed to the following in struts.xml to make it work. Thank you for providing good code

<action name="ajaxSubmit" class="com.action.AjaxAction" method="loadData">
<result type="json">/pages/ajaxExample.jsp</result>
</action>
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic