admin管理员组文章数量:1310854
I'm trying to write a simple redirection using javascript and blade engine, and this is an example of what i want to do:
javascript code:
<p>Click the button to go to the home page</p>
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction()
{
var x;
var r=confirm("Are you sure you want to leave this page ?");
if (r==true)
{
//Redirect to home
}
else
{
//stay here
}
document.getElementById("demo").innerHTML=x;
}
</script>
when i use return Redirect::route('home')
it does not work, what is the right syntax to do that, and sorry for my bad english.
I'm trying to write a simple redirection using javascript and blade engine, and this is an example of what i want to do:
javascript code:
<p>Click the button to go to the home page</p>
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction()
{
var x;
var r=confirm("Are you sure you want to leave this page ?");
if (r==true)
{
//Redirect to home
}
else
{
//stay here
}
document.getElementById("demo").innerHTML=x;
}
</script>
when i use return Redirect::route('home')
it does not work, what is the right syntax to do that, and sorry for my bad english.
1 Answer
Reset to default 6$url=URL::to('foo'); // any other route name, like home, or use URL::route()
<script>
function myFunction()
{
var x;
var r=confirm("Are you sure you want to leave this page ?");
if (r)
{
window.location="{{URL::to('home')}}";
}
...
More info: http://laravel./docs/routing
本文标签: phpLaravel 4 redirect to a route inside javascript code Blade templateStack Overflow
版权声明:本文标题:php - Laravel 4- redirect to a route inside javascript code Blade template - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741861402a2401644.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论