我在 ajax 加载的表单上遇到了一些关于 serialize() 的问题。
jQuery代码:
$(document).on("submit", this.id, function(e) {
e.preventDefault();
var frm = e.target.id;
var frmData = $("#"+frm).serialize();
console.log(frm);
console.log(frmData);
});
控制台输出:
- 登录表单
- (空文本)
表单本身(引导程序):
<div class="tab-pane active" id="logintab">
<div class="well">
<form class="form-horizontal" id="loginForm">
<div class="control-group">
<label class="control-label" for="inputEmail">E-mail adres</label>
<div class="controls">
<input type="email" id="inputEmail" value="info@domainname.com" placeholder="E-mail adres" data-validation-email-message="Not a valid e-mail address" required>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<div class="controls">
<input type="password" id="inputPassword" value="test" placeholder="Wachtwoord" data-validation-required-message="Not a valid password" required>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn submitbtn"><i class="icon-signin"></i> Inloggen</button>
</div>
</div>
</form>
</div>
</div>