Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.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
Javascript Laravel 5.4-pjax响应一个错误不可处理的实体_Javascript_Php_Jquery_Laravel_Pjax - Fatal编程技术网

Javascript Laravel 5.4-pjax响应一个错误不可处理的实体

Javascript Laravel 5.4-pjax响应一个错误不可处理的实体,javascript,php,jquery,laravel,pjax,Javascript,Php,Jquery,Laravel,Pjax,我使用了来自 当我点击登录和注册链接(基本laravel auth)时,它工作正常。Pjax正在工作,但当我尝试登录时,它显示了一个错误 (1/1) HttpException in Application.php (line 926) at Application->abort(422, '', array()) in helpers.php (line 30) at abort(422) in FilterIfPjax.php (line 87) at FilterIfPjax->

我使用了来自

当我点击登录和注册链接(基本laravel auth)时,它工作正常。Pjax正在工作,但当我尝试登录时,它显示了一个错误

(1/1) HttpException
in Application.php (line 926)
at Application->abort(422, '', array())
in helpers.php (line 30)
at abort(422)
in FilterIfPjax.php (line 87)
at FilterIfPjax->fetchContainer(object(Crawler), '#body')
in FilterIfPjax.php (line 54)
at FilterIfPjax->filterResponse(object(Response), '#body')
in FilterIfPjax.php (line 35)
at FilterIfPjax->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
...
我的代码中缺少什么? 我不知道如何修正这个错误。任何人都可以解释为什么会发生这种错误

<script type="text/javascript">
        $(document).ready(function(){
            if ($.support.pjax) {
                $.pjax.defaults.timeout = 2000; // time in milliseconds
                $(document).pjax('a', '#body');
                $(document).on('submit', 'form[data-pjax]', function(event) {
                    $.pjax.submit(event, '#body');
                });
            }
        });
    </script>

$(文档).ready(函数(){
if($.support.pjax){
$.pjax.defaults.timeout=2000;//时间(毫秒)
$(document.pjax('a','#body');
$(文档).on('submit','form[datapjax]',function(event){
$.pjax.submit(事件“#body”);
});
}
});
这是使用pjax提交表单的正确方法吗(无需重新加载页面)

这是我的应用程序布局

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}"></script>
    <script type="text/javascript" src="{{asset('js/jquery.pjax.js')}}"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            if ($.support.pjax) {
                $.pjax.defaults.timeout = 2000; // time in milliseconds
                $(document).pjax('a', '#body');
                $(document).on('submit', 'form[data-pjax]', function(event) {
                    $.pjax.submit(event, '#body');
                });
            }
        });
    </script>
</head>
<body id="body">
    ....
   @yield('content')
</body>
</html>

{{config('app.name','Laravel')}
$(文档).ready(函数(){
if($.support.pjax){
$.pjax.defaults.timeout=2000;//时间(毫秒)
$(document.pjax('a','#body');
$(文档).on('submit','form[datapjax]',function(event){
$.pjax.submit(事件“#body”);
});
}
});
....
@产量(‘含量’)

我发现当我删除pjax插件并尝试正常登录时,它显示了一个错误

SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)
所以我意识到我忘了在.env文件中配置DB_用户名和DB_密码

我输入了正确的用户名和密码,并重新安装了pjax插件。它工作得很好。:)

我认为如果请求中有错误,FilterIfPjax类将抛出错误422。。我不确定:)