• 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

request submission struts/jquery

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using JQuery with Struts 1.1. I am using following code when user
clicks on Save button:


$('#save').click(function() {
$.blockUI({ message: "Please wait..." });


$.ajax({
url: '/saveData.do?dispatch=save',
type:'post',
cache: false,
dataType:'xml',
complete: function() {
$.unblockUI();
}
});

In my struts code,

<html:form action="/saveTemplate.htm?dispatch=save" method="POST">
<div id="firstchildcontainer">
Name: <html:text property="templateName"/>
Description: <html:textarea property="description" rows="8"
cols="10"/>
<html:submit styleId="save"><bean:message key="button.save"/></
html:submit>
<html:cancel styleId="cancel"><bean:message key="button.cancel"/></
html:cancel>
</div>
</html:form>


The problem here is it is submitting request twice because it is
defined with struts form and with url (in ajax). How can I avoid
duplicate request?


Thanks,
Bhavin
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a JavaScript question, not Struts.

You need to return false from your JavaScript handler to prevent the default click handler from running after the Ajax request.
 
Bhavin Sanghani
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I tried "return false;" at end of ajax call and it submits one request but it does not populate form fields in actionForm.

can anyone give example of Jquery + Struts 1?

Thanks,
Bhavin
 
reply
    Bookmark Topic Watch Topic
  • New Topic