• Post Reply Bookmark Topic Watch Topic
  • New Topic

Call post method onClick img tag

 
Samar Land
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking for a good way to do this action,

When user click on image run the post method of the spring controller.





Any advice?
 
Samar Land
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


kind of my options

using this, it calls the Get method not the post method
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • You'll need to use JavaScript for this.
  • You should use jQuery for event handling; using onclick is not considered a good practice
  • Assuming you want a whole page submit, you'll need to submit a hidden form to get a POST
  •  
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 65516
    105
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Also, I'm curious: what did you think that would do for you that just would not?
     
    Samar Land
    Ranch Hand
    Posts: 62
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Bear Bibeault wrote:Also, I'm curious: what did you think that would do for you that just would not?

    Oops, Both way worked the same :/
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 65516
    105
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Samar Land wrote:
    Oops, Both way worked the same :/

    Right. Activity on the client side -- such as reacting to input, mouse clicks, and so on, are handled with JavaScript in the page, not JSP notation that gets evaluated on the server long before the page is sent to the browser.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!