问题阐述:引用bootstrap模态框,当点击表单弹出框的确认按钮是应当像预先设定好的路由发送请求,但是请求并没有发送。
解决思路:浏览器和后台没有任何报错,路由是没问题的,地址也正确;问题应该出在按钮本身,查了下资料,提交按钮后面的data-dismiss="modal"去掉即可//注意:提交按钮的type="submit"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<form class="modal-content" action="/admin/delete" method="get">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">请确认</h4>
</div>
<div class="modal-body">
<label>是否删除?</label>
<input type="hidden" name="id" id="userDeletId">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<!--问题代码-->
<!-- <button type="button" d="btn_submit" class="btn btn-primary" data- dismiss="modal">确认</button> -->
可以写成
<!-- <button type="submit" id="btn_submit" class="btn btn-primary" >确认</button> -->
或
<input type="submit" id="btn_submit" class="btn btn-primary" value="确认">
</div>
</form>
</div>
</div>
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>