How to pass a value from a JS function to a laravel controller?

I am having problems with JQ controller and laravel.

Since this is a JS file that should call the controller with a value in it.

function follow_or_unfollow(id,action)
{
    either route call
        myUrl = "{{ route('follows.show','id') }}" ;

    or controller call

 myUrl = "{{ action('FollowsController@show', 'id') }}" ;

bla bla bla !

}

I need to: send the id value, typing where "id" is specified. currently it prints as id instead of id value. I tried a few things like

'+id+'

'"+id+"'

and sending data to others. but the laravel controller does not expect to receive data in the route / action method from outside. Any help would be appreciated. Thanks in advance.

0
source share
1 answer

Find a solution that works great right now. Thanks Charletfl!

, . :

function follow_or_unfollow(id,action)
{
    either route call
        myUrl = "http://foofoo.com/+id" ;

    or controller call

 myUrl = "http://foofoo.com/+id" ;

bla bla bla !

}

, , . : / php, .

, !

0

All Articles