File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 8710
    
    6

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: 8710
    
    6

Struts 2 JSON Plugin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling struts2 action from javascript
 
Similar Threads
Struts2
struts2 - setting result JSP at runtime
Struts2 & XmlHttpRequest & input_file & Html5
Struts2 Annotations
Working with Struts2