I want to do this in laravel: https://laravel.com/docs/5.6/redirects
I have a simple button, a named route, and I want the route to redirect to another page.
Although I see the new page in the network console of Chrome, the page itself is not actually redirecting.
(I don't want to use the window.location.href in the javascript function as I want the route to do the job.)
layout.blade.php
$("#myRedirectButton").click(function(){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
method: 'post',
dataType: 'text',
url: 'redirect-testing-link',
success: function (data)
{
}
});
});
routes/web.php
Route::post('/redirect-testing-link', function () {
return redirect()->route('gidis');
});
Route::get('/gosterge_paneli', function () {
return view('gosterge_paneli');
})->name('gidis');