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
Post a Comment