Get base_url using Jquery in Laravel

后端 未结 3 752
孤城傲影
孤城傲影 2020-12-18 05:55

I am using laravel 5.0. I want to get base url of laravel page using jquery. I have tried the following function.

function getBaseURL () {
   return location         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-18 06:26

    Do you mean you want the base url of your laravel app available anywhere your javascript?

    You can include this in your template.blade.php:

    
    

    And than access that var anywhere in your javascript:

    console.log(APP_URL);
    

提交回复
热议问题