需求场景:有时候单纯的form表单无法向后端传递额外的参数 比如需要action传递js异步生成的参数 ,form表单默认的action就无法满足需求,这时就需要我们自定义form表单的提交方式。
html:(向后台传递对任务的评论内容,默认缺点:不能携带任务id)
1 <div> 2 <form action="#" id="form_comment"> 3 <textarea id="comment" required="required" class="form-control" name="comment" 4 data-parsley-trigger="keyup" data-parsley-minlength="20" data-parsley-maxlength="100" 5 data-parsley-validation-threshold="10" placeholder="评论......"></textarea> 6 <div style="padding: 4px 0 0 0"> 7 <button type="submit" class="btn btn-success" id='commentSb' 8 style="background: #fff;color: #0c0c0c;border-color: #CCC"><font 9 style="vertical-align: inherit;"><font style="vertical-align: inherit;">提交</font></font> 10 </button> 11 <button type="button" class="btn btn-primary" id='commentCel'><font 12 style="vertical-align: inherit;float: right"><font 13 style="vertical-align: inherit;">取消</font></font></button> 14 </div> 15 </form> 16 </div>