我无法使用ajax发布将带有UserId和Multi select复选框的表单发布为列表。
<html>
<head>
</head>
<body>
<form method="POST" >
<div> <input type="Text" name='UserId' value="Ram" ></div>
<div id="Activity">
<input type="checkbox" name="aa" Id="bb_1" value="1" >
<input type="checkbox" name="aa" Id="bb_2" value="2">
<input type="checkbox" name="aa" Id="bb_3" value="3">
<input type="checkbox" name="aa" Id="bb_4" value="4">
<input type="checkbox" name="aa" Id="bb_5" value="5">
</div>
<input type="submit" class="button-default" value="Submit"/>
</form>
<script>
$("form").submit(function (e) {
var formData = new FormData($(this)[0]);
$.ajax({
url: "http://localhost:55798/API/Applyjob",
type: "POST",
data: formData,
async: false,
success: function (msg) {
alert(msg);
},
cache: false,
contentType: false,
processData: false,
});
e.preventDefault();
$('input[type=checkbox]').prop('checked', false);
window.location.reload();
});
</script>
</body>
</html>
我要发布带有多个选定复选框值的表单,例如列表。那么如何使用ajax表单发布方法来发布此表单?