i have a code in jQuery which first validate the form using ajax and then resubmit the same form to another location but while resubmitting the submit button value not sending.. What will be the issue??
here's the js code:
$.ajax({
'type': 'post',
'url': '/inc/do.php',
'data': $form.serialize(),
beforeSend: function(){
$form.find(':input').attr('disabled', true);
$form.find('.btn').addClass('bdsbld');
$form.find('.blkr').css('display', 'block');
},
error: function(){
Recaptcha.reload();
$form.find(':input').attr('disabled', false);
$form.find('.btn').removeClass('bdsbld');
$form.find('.blkr').css('display', 'none');
},
success: function(d){
$form.find(':input').removeAttr('disabled');
if(res=isJSON(d)){
if(!res.err && res.msg.toLowerCase()==='ok'){
if(($PRI_KEY=$form.find('input#PRIVATE_KEY')).length) $PRI_KEY.val(res.PRIVATE_KEY);
$form.append('<input type="hidden" id="PRIVATE_KEY" name="PRIVATE_KEY" value="'+res.PRIVATE_KEY+'" />');
$form.find('input#do').val('BOOK_AD');
$form.find('#reCaptchaO').remove();
form.submit();
}
else{
alert(res.msg);
Recaptcha.reload();
$form.find('.btn').removeClass('bdsbld');
$('#'+res.fld).delay(250).focus();
}
}
else
if(d!==''){
alert(d);
Recaptcha.reload();
$form.find('.btn').addClass('bdsbld');
}
$form.find('.blkr').css('display', 'none');
}
});
in this code, the line i.e.
form.submit();
is re-submitting the form but it is not including the submit button and its value but the submit button was included in the ajax request... why??
Submit buttons are only considered successful controls if they are used to submit the form. Since you are submitting the form using JavaScript, you aren't using the submit button, so it isn't successful, and it isn't included in submitted request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With