Laravel重定向,a链接跳转,控制器跳转示例
吾爱主题
阅读:139
2021-09-10 13:53:00
评论:0
Laravel重定向分类如下:
1、a链接跳转:
?1 | < a class = "btn btn-success" href="{{url('admin/organization/createAuthCodeView', ['id' => $list['id']])}}" rel="external nofollow" >生成注册码</ a > |
2、form表单提交跳转:
?1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <form class = "form-inline" method= "get" action= "{{ url('admin/organization/listOrganization') }}" > <div class = "form-group" style= "margin-left: 20px" > <input type= "hidden" name= "customer_type" value= "1" > <label for = "perPage" >每页显示数:</label> <select class = "form-control" id= "perPage" name= "perPage" > @ foreach ( [10,20,30,50] as $e ) <option value= "{{$e}}" {{ $e ==request( 'perPage' ) ? 'selected' : '' }} >{{ $e }}</option> @ endforeach </select> </div> <div class = "form-group" style= "margin-left: 20px" > <label for = "search" >模糊搜索:</label> <input type= "text" name= "search" style= "width: 400px" class = "form-control" id= "search" placeholder= "请输入用户名或者邮箱或者电话" value= "{{request('search')}}" > </div> <button type= "submit" class = "btn btn-primary" style= "margin-left: 20px" >开始搜索</button> <a href= "{{url('admin/organization/createOrganization')}}" rel= "external nofollow" class = "pull-right" > <button class = "btn btn-primary" >新增机构</button> </a> </form> |
3、ajax提交跳转:
?1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <script type= "text/javascript" > $( function (){ $.ajaxSetup({ headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' } }); $( "#generate" ).click( function (){ $.ajax({ url: "/admin/organization/generateAuthCode" , //你的路由地址 type: "post" , data:{ "auth_num" :$( '#auth_num' ).val(), "organization_name" :$( '#organization_name' ).val()}, timeout:30000, success: function (data){ $( "#auth_codes" ).val(data); }, error: function (){ console.log(data); } }); }); }) </script> |
4、控制器方法里面跳转:
?1 | return redirect( '/admin/organization/listOrganization' ); |
以上这篇Laravel重定向,a链接跳转,控制器跳转示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/zhezhebie/article/details/78328091
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。