Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何返回重定向到Laravel中的模态?_Jquery_Laravel_Laravel 4_Laravel 5 - Fatal编程技术网

Jquery 如何返回重定向到Laravel中的模态?

Jquery 如何返回重定向到Laravel中的模态?,jquery,laravel,laravel-4,laravel-5,Jquery,Laravel,Laravel 4,Laravel 5,我有一个模式,当我的用户点击登录时会触发。 思维方式 如果身份验证失败,我想重新引导回到这个模式 考虑到这一点,我想重新导演: 回到我的主页 触发此模式 在那里闪现我的会话 HTML Btn 登录 模态 <!--Login Modal--> <div class="light-skin modal fade" id="loginModal" tabindex="-1" role="form" aria-hidden="true"> <div class

我有一个模式,当我的用户点击登录时会触发。


思维方式 如果身份验证失败,我想重新引导回到这个模式

考虑到这一点,我想重新导演:

  • 回到我的主页
  • 触发此模式
  • 在那里闪现我的会话

HTML Btn

登录

模态

<!--Login Modal-->
<div class="light-skin modal fade" id="loginModal" tabindex="-1" role="form" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Login here</h4>

        {{-- Session     --}}
         @include('layouts.session')


      </div>
      <div class="modal-body">
        <form class="login-form" role="form" method="post" action="/">
          <div class="form-group">
            <label for="username">Username</label>
            <input type="text" class="form-control"  id="username" name="username" placeholder="Enter Username" required>
          </div>
          <div class="form-group">
            <label for="password">Password</label>
            <input type="password" class="form-control" id="password" name="password" placeholder="Enter Password" required>
          </div>
          <button type="submit" class="btn btn-primary">Login</button>

          {!! Form::token() !!}
          </form>

      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

没有什么是导火索。有人给我任何提示吗?

多亏了@Tim Lewis@Kryten为我指明了正确的方向

我相信有不止一种方法可以做到这一点,但这里我如何让我的工作

<?php $error = Session::get('error');  ?>

// If there is error, the modal will be trigger.
@if(!empty($error) )
<script>
$(function() {
    $('#loginModal').modal('show');
});
</script>
@endif

//如果出现错误,将触发模式。
@如果(!empty($error))
$(函数(){
$('loginModal').modal('show');
});
@恩迪夫

示例:

模式是否通过Javascript触发?如果是这样的话,你需要在页面加载时通过Javascript来完成。我可以看到2个选项:1。使用某种标志/会话变量重新加载页面,该变量指定应打开模式或2。通过
ajax
执行您的后端工作,并且永远不要实际关闭模式/重定向页面。
<?php $error = Session::get('error');  ?>

// If there is error, the modal will be trigger.
@if(!empty($error) )
<script>
$(function() {
    $('#loginModal').modal('show');
});
</script>
@endif