Reputation: 99
I am using JQuery, Ajax and Struts for a web application. I am trying to submit when a button clicked. I have 4 tabs in one page. I placed 4 buttons on each tab and I want to submit the whole form when user clicked on a button through Ajax. When I submit form, I am getting values for all the form fields except button1 value as null in the form bean. Do I have any alternative to track what button clicked while submitting the whole form? Is there any way I can pass additional parameter along with submitting whole form in ajax? Thank you!
$('[name=button1]').click(function()
{
$.ajax(
{
type: "POST",
url: "/NB/AjaxSubmit.do",
data: $('form[name=ajaxForm]').serialize(), // serializes the form's elements.
success: function(data)
{
alert(data); // show response from the php script.
}
});
return false; // avoid to execute the actual submit of the form.
});
<html:button property="button1" value ="Submit"></html:button>
Upvotes: 0
Views: 729
Reputation: 64466
Change the type
from button to submit
,button values are not passed with form values
or append in the button value in the ajax url
url: "/NB/AjaxSubmit.do?mybutton="+$('[name=button1]').attr('value'),
Upvotes: 1