提交按钮需要单击两次以提交表单 [英] Submit button needs to be clicked twice to submit form
问题描述
我的代码中具有以下jquery函数.我必须单击两次提交"按钮才能使表单提交工作.我可以使用ajaxSubmit函数,然后一切正常,但是jquery的问题在于,提交按钮的值本身未作为发布的一部分传递.
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.
我已经在所有子页面上进行了isset($_POST['submit'])
检查,并使用ajaxSubmit
从未设置此条件.
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() {
}
});
如何使用ajaxSubmit函数并通过表单提交提交"按钮值? 提交表单时,我需要设置Submit变量. ajaxForm可以做到,但是我需要单击两次提交按钮.解决方案是ajaxSubmit,但它不会自行设置Submit变量.
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.
推荐答案
关于您的问题的"ajaxSubmit"部分: 您可以将任何参数添加到ajaxSubmit调用中,因此您的表单参数和所有添加的参数将被提交:
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() {
}
});
}
});
这篇关于提交按钮需要单击两次以提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!