问题
I am having trouble with JQ and laravel controller.
As this is a JS file which need to call a 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 !
}
What I need is : to send the value of the id by printing there at the place where 'id' is mentioned. at this moment it is printing as id instead of value of the id. I have tried several things like
'+id+'
'"+id+"'
and sending data by other ariable. but laravel controller expect to receive data within the route / action method not from outside. Any help will be apreciated. Thanks in advance.
回答1:
Find a solution that works fine at this moment. Thanks Charletfl !
yes the link can do this job as alternative. like this :
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 !
}
in this way the variable value can be passed to the controller but still a researchable question is raised. Like : if we want to implement/print a value inside a php tag what should we do ..
Thanks for helping friends !
来源:https://stackoverflow.com/questions/20175881/how-to-pass-a-value-from-a-js-function-to-a-laravel-controller