mercredi 29 décembre 2021

include script in header for get params laravel

I´m traying to include in my blade other blade that contain script js to get any configuration parameters. But when load my page return this:

Uncaught SyntaxError: Invalid hexadecimal escape sequence

and

Uncaught ReferenceError: phpToJs is not defined

i´m inclining into my blade like this:


        @include('layouts.php_to_js')

and my blade contain this:

<script type="text/javascript">
    // global app configuration object
    var phpToJs = {
        url: {
            app_path: '{!! app_path() !!}',
            base_path: '{!! base_path() !!}',
            config_path: '{!! config_path() !!}',
            database_path: '{!! database_path() !!}',
            public_path: '{!! public_path() !!}',
            resource_path: '{!! resource_path() !!}',
            storage_path: '{!! storage_path() !!}',
            base_url: '{!! config("app.url") !!}',
            base_url_admin: '{!! config("app.url") !!}admin/',
            currentName: '{!! Route::currentRouteName() !!}',
            currentFull: '{!! Request::fullUrl() !!}',
            currentUrl: '{!! URL::current() !!}',
        },
        csrf: '{!! csrf_token() !!}',
        language: '{!! session()->get("language") !!}',
    };

</script>

i´m using this for to can use name routes in external files js (external to blade).If i show code for my website, it´s result:

<script type="text/javascript">
    // global app configuration object
    var phpToJs = {
        url: {
            app_path: 'C:\xampp\htdocs\gdsRepository\app',
            base_path: 'C:\xampp\htdocs\gdsRepository',
            config_path: 'C:\xampp\htdocs\gdsRepository\config',
            database_path: 'C:\xampp\htdocs\gdsRepository\database',
            public_path: 'C:\xampp\htdocs\gdsRepository\public',
            resource_path: 'C:\xampp\htdocs\gdsRepository\resources',
            storage_path: 'C:\xampp\htdocs\gdsRepository\storage',
            base_url: 'http://localhost/gdsRepository/public/',
            base_url_admin: 'http://localhost/gdsRepository/public/admin/',
            currentName: 'admin.precontratos.create',
            currentFull: 'https://localhost/gdsRepository/public/index.php/admin/precontratos/create',
            currentUrl: 'https://localhost/gdsRepository/public/index.php/admin/precontratos/create',
        },
        csrf: 'eoEE6xbNUQu53ze90x7dr1pCSE5lrEGugXsQldia',
        language: '',
    };

</script>    </head>

my script it´s there, but i can´t use it... any idea to solve my problems?

Thanks for read and help me. Sorry for my english



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ED8KTS
via IFTTT

Aucun commentaire:

Enregistrer un commentaire