Laravel中的几种跳转方式

1、a链接跳转:

<a class="btn btn-success" href="{{url('admin/organization/createAuthCodeView', ['id' => $list['id']])}}">生成注册码a>

2、form表单提交跳转:

<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')}}" class="pull-right">
    <button class="btn btn-primary">新增机构button>
  a>
form>

3、ajax提交跳转:

<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、控制器方法里面跳转:

return redirect("errors/403?from={$url}");

你可能感兴趣的:(Laravel,laravel)