php - Laravel 4- redirect to a route inside javascript code Blade template -


I am trying to write a simple redirection using javascript and blade engine, and this is an example I Wish:

Javascript code:

  & lt; P & gt; Click the button to go to the home page & lt; / P & gt; & Lt; Button onclick = "myfunction ()" & gt; Click me & lt; / Button & gt; & Lt; P id = "demo" & gt; & Lt; / P & gt; & Lt; Script & gt; Function myFunction () {var x; Var r = Confirmation ("Are you sure you want to leave this page?"); If (R == true) {// Redirection at home} Other {// here to stay} Documents. Gate Element BIID ("Demo"). InnerHTML = x; } & Lt; / Script & gt;   

When I use Return Redirect :: Route ('Home') This does not work, what is the correct syntax for doing this, and my Sorry for the bad English.

$ url = URL :: to ('af'); // Use the name of any other route, such as home, or URL :: route ()

  & lt; Script & gt; Function myFunction () {var x; Var r = Confirmation ("Are you sure you want to leave this page?"); If (r) {window.location = "{{URL :: to ('home')}}"; } ...   

More info:

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -