在提交表单时使用jquery使用动态表单提交,显示错误
“由于未连接表单而取消了表单提交”
$('<form method="POST" action="http://localhost/almadar/appointment-form">
<input type="hidden" name="dept" value="'+dept+'">
<input type="hidden" name="doctor" value="'+doctor+'">
<input type="hidden" name="hours" value="'+hours+'">'
).submit();
答案 0 :(得分:1)
将表格插入dom,然后提交:
var $form = $('<form method="POST" action="http://localhost/almadar/appointment-form"><input type="hidden" name="dept" value="'+dept+'"><input type="hidden" name="doctor" value="'+doctor+'"><input type="hidden" name="hours" value="'+hours+'">')
.appendTo('body')
$form.submit()