Reputation: 626
I have the following jquery function in my code. I have to click the 'submit' button twice to get the form submit to work. I could use ajaxSubmit function and then everything works fine but the problem with jquery is that the submit button's value itself is not passed as part of post.
I have isset($_POST['submit'])
check on all my subpages and using ajaxSubmit
, this criteria is never set.
$("#bulkeditshowForm").validate({
submitHandler: function(form) {
$('#bulkeditshowForm').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#bulkeditResult',
beforeSubmit: function(){
},
success: function() {
}
});
How do I use ajaxSubmit function and also submit the 'submit' button value through the form? I need to the submit variable set when the form is submitted. ajaxForm does it, but I need to click the submit button twice. ajaxSubmit is the solution but it doesn't set the submit variable itself.
Upvotes: 0
Views: 1260
Reputation: 1425
About "ajaxSubmit" part of yor question: Your can add any parameters to ajaxSubmit call, so your form parameters and all added parameters will be submitted:
//Take submit button value
var submitButtonValue = $("#submitButtonId").val();
$("#bulkeditshowForm").validate({
submitHandler: function(form) {
$('#bulkeditshowForm').ajaxForm({
// target identifies the element(s) to update with the server response
target: '#bulkeditResult',
//add submit button value to ajaxSubmit
data: {'your_parameter_name':submitButtonValue},
beforeSubmit: function() {
},
success: function() {
}
});
}
});
Upvotes: 1
Reputation: 2493
Not good in jquery but you can change submit button name and use that name which you check in pages in input type hidden
Upvotes: 0