Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
306 views
in Technique[技术] by (71.8m points)

jQuery not working after using renatomarinho / laravel-page-speed package?

I wanted to minify html output so I have used the renatomarinho/laravel-page-speed package. I have done as per the instruction on its github page https://github.com/renatomarinho/laravel-page-speed. But for some reason now the jquery stopped working after installing this package. I thought this issue was caused due to the comments in javascript file so i have removed all the comments from the js library files that I have included. But still jquery is not working. Please help me out. Please check the attached image.

error image

javascript code

<script src="{{ asset('backend/assets/plugins/global/plugins.bundle.js') }}?v={{ time() }}"></script>
<script src="{{ asset('backend/assets/plugins/custom/prismjs/prismjs.bundle.js') }}?v={{ time() }}"></script>
<script src="{{ asset('backend/assets/js/scripts.bundle.js') }}?v={{ time() }}"></script>
<!--end::Global Theme Bundle-->
<!--begin::Page Scripts(used by this page)-->
<script>
    $(document).ready(function(){

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        $("#loginform").submit(function(e){
            e.preventDefault();
            var status=false;
        
            if($(".email").val()==""){
                $(".email_error").html("Email address is mandatory");
                $(".email_error").show();
                status=false;
            } else {
                $(".email_error").hide();
                status=true;
            }

            if($(".email").val()!==""){
                if(validateEmail($(".email").val())==false){
                    $(".email_error").html("Invalid Email address");
                    $(".email_error").show();
                    status=false;
                } else {
                    $(".email_error").hide();
                    status=true;
                }
            }

            if($(".password").val()==""){
                $(".password_error").html("Password is mandatory");
                $(".password_error").show();
                status=false;
            } else {
                $(".password_error").hide();
                status=true;
            }

            if(status==true){
                var formdata=$("#loginform").serialize();
                $.ajax({
                    url:"{{ route('admin.loginprocess') }}",
                    type:"post",
                    async:false,
                    data:formdata,
                    success:function(res){
                        if(res.status=='fail'){
                            $(".alert-danger").html("Invalid email or password");
                            $(".alert-danger").removeClass('d-none');
                            $(".alert-success").addClass('d-none');
                       }
                       if(res.status=='success'){
                            $(".alert-success").html("Login Successful");
                            $(".alert-success").removeClass('d-none');
                            $(".alert-danger").addClass('d-none');
                            setTimeout(function(){ window.location="{{ route('admin.dashboard') }}"; }, 1500);
                       }
                    }
                });
            }
        });
    });

    function validateEmail(email) {
        const re = /^(([^<>()[]\.,;:s@"]+(.[^<>()[]\.,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
        return re.test(String(email).toLowerCase());
    }
</script>
question from:https://stackoverflow.com/questions/65841135/jquery-not-working-after-using-renatomarinho-laravel-page-speed-package

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  • open : App/Http/Kernel.php
  • coment : /RenatoMarinhoLaravelPageSpeedMiddlewareDeferJavascript::class,

work for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...