How to escape a javascript variable for the Laravel blade?

0

Hello, I have this javascript function that gets a parameter:

function teste(id){
  document.getElementById("campo1").innerHTML = id;
  document.getElementById("campo2").innerHTML = {{app\User::find("id")->titulo}}
}

How do I get the User :: find () function to get the 'id' variable that is javascript, is there any way to do this?

    
asked by anonymous 24.02.2016 / 21:35

1 answer

1

Can not teste(id) function runs at run-time on front-end, {{app\User::find("id")->titulo}} is Blade which in turn is part of Laravel which is a PHP framework and runs on the backend is processed and delivered the front end is ready.

So you can not do this and is not a logical thing to do, it is best to change the strategy, but it will depend on what User::find("id")->titulo has to do and what teste() really does. As it is difficult to give an alternative.

    
24.02.2016 / 21:42