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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -