serialize() does not registed the hidden value that were assigned using jquery.
Hi
I have a form with in it i have 2 <input type="hidden" and the values are currently empty. However, thru my jquery code i assign value to it. now when i want to pass the values using ajax to php file those new input will have no values! here in my code.
I think i need to use Live() function somewhere in my code for this to work but i can't seems to figure it out.
Note: I am using the dialog UI to show a form
$(function() {
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 450,
width: 700,
modal: true,
buttons: {
"Make Payment": function(e) {
$("#additionlResult").html('').removeClass();
e.preventDefault()
//$('#Paying_Res_id').show(); // Show them
//$('#Paying_Res_Total').show(); // Show them
var formData = $('#makePaymentForm').serialize();
//$('#Paying_Res_id').hide(); // hide them
//$('#Paying_Res_Total').hide(); // hide them
submitForm(formData);
},
Cancel: function() {
$("#additionlResult").removeClass().text('');
$('#makePaymentForm')[0].reset();
$( this ).dialog( "close" );
},
Reset: function() {
$("#additionlResult").removeClass().text('');
$('#makePaymentForm')[0].reset();
}
},
close: function() {
$("#additionlResult").removeClass().text('');
$('#makePaymentForm')[0].reset();
$( this ).dialog( "close" );
}
});
$("input[id^='payCredit_']").click(function() {
var button_name = $(this).attr('id');
var id = button_name.replace('payCredit_', '');
var total = $('#totalOwe_' + id).val();
$('#Paying_Res_id').val(id);
$('#Paying_Res_Total').val(total);
$('#balance').val(total);
$( "#dialog-form" ).dialog("open");
});
});
function submitForm(formData) {
$.ajax({
type: 'POST',
url: 'payCredit.php',
data: formData,
dataType: 'json',
cache: false,
timeout: 7000,
success: function(data) {
$('#additionlResult').removeClass().addClass((data.error === true) ? 'errorBox' : 'passBox').html(data.msg).fadeIn('fast');
if ($('#additionlResult').hasClass('passBox')) {
//$("#additionlResult").removeClass().text('');
//$("#dialog-form").dialog("close");
//refresh the page
//location.reload();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$('#additionlResult').removeClass().addClass('errorBox')
.html('<p>There was an<strong> ' + errorThrown +
'</strong> error due to a<strong> ' + textStatus +
'</strong> condition.</p>').fadeIn('fast');
},
complete: function(XMLHttpRequest, status) {
/*
if( $('#additionlResult').hasClass('passBox')){
$('#additionalDriverForm')[0].reset();
$('#additionlResult').removeClass();
}
*/
}
});
};