我在一个页面中有两个表单,我想通过一个提交按钮提交两个表单。我在Stackoverflow中尝试过其他解决方案,但无法得到它。它没有重定向到demo.php。在我的代码下面。
<form id="form1" class="multiple-choice">
<input id="check1" type="checkbox" name="check" value="check1" class="input-checkboxitem">
<label for="check1">Materials</label>
<br>
<br>
<input id="check2" type="checkbox" name="check" value="check2" class="input-checkboxitem">
<label for="check2">Exam Method</label>
<br>
<br>
<input id="check3" type="checkbox" name="check" value="check3" class="input-checkboxitem">
<label for="check3">Learning Method</label>
<br>
<br>
<input id="check4" type="checkbox" name="check" value="check4" class="input-checkboxitem">
<label for="check4">Evaluation</label>
<br>
<br>
<input id="check5" type="checkbox" name="check" value="check5" class="input-checkboxitem">
<label for="check5">User Friendliness</label>
<br>
<br>
<input id="check6" type="checkbox" name="check" value="check6" class="input- checkboxitem">
<label for="check6">None</label>
</form>
<form id="form2">
<input type="radio" name="radiog_dark" id="radio4" class="css-checkbox" />
<label for="radio4" class="css-label radGroup2">Yes</label>
<input type="radio" name="radiog_dark" id="radio5" class="css-checkbox">
<label for="radio5" class="css-label radGroup2">No</label>
<input type="radio" name="radiog_dark" id="radio6" class="css-checkbox">
<label for="radio6" class="css-label radGroup2">May be</label>
<input type="submit" name="submit" value="submit"></input>
</form>
<div class="form_result"></div>
$(document).ready(function(){
$('form input[type ="radio"], input[type ="checkbox"]' ).click(function(){
$.ajax({ type:'POST', url:'demo.php', data:$('#form1, #form2).serialize(), success:function(response){
console.log(response);
$('body').find('.form_result').html(response);
}
});
return false;
});
});