<strike id="iz7t7"></strike>
    1. <sub id="iz7t7"></sub>
    2. <sub id="iz7t7"><del id="iz7t7"></del></sub>
      1. <blockquote id="iz7t7"></blockquote>

        laravel 返回ajax请求错误信息

        laravel 创建验证的 表单请求( form request )  执行命令 php artisan make:request StoreBlogPostRequest

        分享图片

         

         

        前段ajax发送请求 

         
        $(‘#reg_reg‘).click(function () {
                var formData = new FormData($( "#reg_form" )[0]);
                var url = "{{ url(‘/admin/register‘) }}";
        
                $.ajax({
                    headers: {
                        ‘X-CSRF-TOKEN‘: $(‘meta[name="csrf-token"]‘).attr(‘content‘)
                    },
                    url: url,
                    type: ‘POST‘,
                    data: formData,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function(res){
                        console.log(res);
                        // if(res.code){
                        //     redirect_success(res.msg, res.url)
                        // }else{
                        //     error(res.msg);
                        // }
                    },
                    error : function (msg ) {
                        var json=JSON.parse(msg.responseText);
                        $.each(json.errors, function(idx, obj) {
                            alert(obj[0]);
                            return false;
                        });
                    },
                })
            })
        相关文章
        相关标签/搜索
        刘伯温三肖选一肖