以下是body标签中的JQuery脚本代码。
<script type="text/javascript">
$("#submit-data").click(function()
{
var form = new FormData($('#patient-personal')[0]);
console.log(form);
});
</script>
以下是我的HTML代码:
<form id="patient-personal" onsubmit="return false;" role="form">
<div class="form-body">
<div class="row">
{{-- Form Start --}}
{{-- First Name --}}
<div class="col-md-4">
<div class="form-group form-md-line-input form-md-floating-label">
<input type="text" class="form-control" name="firstname" id="firstname">
<label for="firstname">First Name</label>
<span class="help-block">Patient's First Name</span>
</div>
</div>
{{-- Last Name --}}
<div class="col-md-4">
<div class="form-group form-md-line-input form-md-floating-label">
<input type="text" class="form-control" name="lastname" id="lastname">
<label for="lastname">Last Name</label>
<span class="help-block">Patient's Last Name</span>
</div>
</div>
{{-- Date of Birth --}}
<div class="col-md-4">
<div class="form-group form-md-line-input form-md-floating-label">
<input type="date" class="form-control" name="dob" id="dob">
{{-- <label for="dob">Date of Birth</label> --}}
<span class="help-block">Patient's Date of Birth</span>
</div>
</div>
</div>
</div>
<a href="javascript:;" id="submit-data" class="btn green button-submit"> Submit</a>
</form>
当我点击提交按钮时,它在Form变量中没有显示任何值。它显示一个空白数组。它背后可能是什么原因?
答案 0 :(得分:-2)
试试这个片段:
$('#patient-personal').serialize();