Skip to content Skip to sidebar Skip to footer

Passing Two Variables In Route Through Javascript Function In Laravel

I am trying to send two variables in route through java script function. Javascript function: function bookmark() { var url = '{{ route('save_bookmark',':b_id',':p_no')

Solution 1:

you can still do it this way!

javascript

functionbookmark()
{       
     var url = '{{ route("save_bookmark",":b_id",":p_no") }}';       
      url1 = url.replace(':b_id', book);
      url2 = url.replace(':p_no', count);
     //document.location.href = url;document.href="https://example.com/save_bookmark/"+url1 +"/"+url2;
      or
     location.href="https://example.com/save_bookmark/"+url1 +"/"+url2;

} 

Solution 2:

Looks Good: try it =>

let val1= "1122";
let val2= "a1b2c3";
    var processUrl = '{{ url("/path/:param1/:param2") }}';
        processUrl = processUrl.replace(':param1', val1);
        processUrl = processUrl.replace(':param2', val2);
    document.location.href = processUrl;

Post a Comment for "Passing Two Variables In Route Through Javascript Function In Laravel"