0
Ola,
I have a form that is sent via Ajax, I had to add some radio inputs. However the method serialize()
does not take the values of the radios (I have two groups of radios in this form), all the other inputs give the right, but with the radios send blank.
Method of sending the form via Ajax:
function sendForm(_formID, _url) {
/* Esse console.log imprime o vlaue de todos os inputs do form, menos do radio selecionado. */
console.log($('#'+_formID).serialize());
$.ajax({
type: 'POST',
url: _url,
data: $('#'+_formID).serialize(),
success: function(data){
alert('success', 4500);
clearAllInputs(_formID);
refreshList(area+'List.php');
console.log('sendForm');
},
error: function() {
alert('error', 4500);
}
});
return false;
};
HTML of one of the radio groups:
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="radioPaymentType" id="radioMoney" value="money" checked>
<label class="form-check-label" for="radioMoney">Dinheiro</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="radioPaymentType" id="radioCheck" value="check">
<label class="form-check-label" for="radioCheck">Cheque</label>
</div>
Way I get in PHP:
$paymentType = $_POST['radioPaymentType'];
I tested here and it worked normal. The console shows in serialize:
radioPaymentType=money
. Even the PHP returnsmoney
.– Sam
@Strange Sam, here does not display the values of the radios. Look at the console.log() of the serialize():
code=&title=Almofada%20e%20ilumina%C3%A7ao%20do%20headset%20com%20problema%20&status=Pendente&client=359&vehicle=117&price=1%2C23&radioPaymentType=&radioPaymentStatus=&dateRegister=2019-06-30&dateExpectedCompleted=&dateCompleted=&detail=123
– RBalconi