• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 93
Python Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
reply
    Bookmark Topic Watch Topic
  • New Topic