my dog learned polymorphism*
The moose likes Struts and the fly likes Calling struts2 action from javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Calling struts2 action from javascript" Watch "Calling struts2 action from javascript" New topic
Author

Calling struts2 action from javascript

Sweta Chauhan
Ranch Hand

Joined: Jul 09, 2010
Posts: 53
I want to call Struts2 action from javascript function. I have searched Google but not able to find any hints to how to do. If anyone have worked on this then please give me any hints.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

You would invoke it the same way you would invoke any URL. If you just need some information and don't want to reload the page, use the AJAX-style XMLHttpRequest (your action should return XML or JSON). If you want to reload the page, use window.location.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Sweta Chauhan
Ranch Hand

Joined: Jul 09, 2010
Posts: 53
Joe Ess wrote:You would invoke it the same way you would invoke any URL. If you just need some information and don't want to reload the page, use the AJAX-style XMLHttpRequest (your action should return XML or JSON). If you want to reload the page, use window.location.


Could you please give me any detail on how to return JSON result.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Struts 2 JSON Plugin
 
wood burning stoves
 
subject: Calling struts2 action from javascript
 
Similar Threads
Struts2
Struts2 & XmlHttpRequest & input_file & Html5
Struts2 Annotations
Working with Struts2
struts2 - setting result JSP at runtime