我正在处理表单,而我似乎无法获取已检查的无线电的participant_type
值。它不断提交给个人"名单。我已经做了一些测试,无论我做什么,我得到的是个人"即使" nonProfit"被选中。我在这里失踪了什么?提前谢谢!
HTML:
<div class="row">
<div class="col-xs-6">
<h4>I Plan to Participate</h4>
<input type="radio" class="participant-type" name="participate_type" checked value="individual">
</div>
<div class="col-xs-6">
<h4>I'm with a Nonprofit</h4>
<input type="radio" class="participant-type" name="participate_type" value="nonProfit">
</div>
</div>
JS:
$('#signup-overlay').hide(); // initiate the overlay as hidden
$('#sign-up-submit').ketchup().on('click', function(e) {
e.preventDefault();
if ($(this).ketchup('isValid')) {
$('#signup-overlay').fadeIn(300);
$('#fail-result').html(' ');
var action = $('#sign-up').attr('action');
var method = $('#sign-up').attr('method');
var first_name = $('#first_name').val();
var last_name = $('#last_name').val();
var email = $('#signup_email').val();
var participant_type = $('.participant-type').val();
var ajax_data = {
url: action,
type: method,
data: {
'first_name': first_name,
'last_name': last_name,
'participantType': participant_type,
'signUpEmail': email
}
};
console.log(JSON.stringify(ajax_data, null, ' '));
$.ajax( ajax_data )
.done(function( data ) {
// $('#signup-result').html( data ).css('color', 'green');
// alert( JSON.stringify(ajax_submit, null, ' '));
})
.fail(function( data ) {
// $('#signup-result').html( 'Sorry, an error occurred.' ).css('color', 'red');
// alert( "error" );
})
.always(function( data ) {
jsonData = JSON.parse(data);
// success
if( jsonData === true ) {
$('#signup-overlay-status').html( '<?php
if( isset( $site_options['signup_success_message'] ) && ( $site_options['signup_success_message'] != "" ) ) {
echo $site_options['signup_success_message'];
} else {
echo "Success!";
}
?>' ).css('color', 'green');
console.log( "Boolean value of True Received");
setTimeout( function() {
$('#ssc-signup').modal('hide');
}, 5000 );
// fail
} else {
$('#signup-overlay').stop( true, true ).fadeOut(300);
$('#fail-result').html( jsonData.error ).css('color', 'red');
console.log( JSON.stringify(jsonData, null, ' '));
}
});
}
});