Get base_url using Jquery in Laravel -


i using laravel 5.0. want base url of laravel page using jquery. have tried following function.

function getbaseurl () {    return location.protocol + "//" + location.hostname + (location.port && ":" + location.port) + "/"; } 

but gives http://localhost. need full base url in jquery. do?

do mean want base url of laravel app available anywhere javascript?

you can include in template.blade.php:

<script type="text/javascript"> var app_url = {!! json_encode(url('/')) !!} </script> 

and access var anywhere in javascript:

console.log(app_url); 

Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

How to connect android app to App engine -