I have created ajax function when the user clicks the button, it will check first the users profile if account is already confirmed. If not, it will redirect back to user dashboard. However, my problem now is that the page is not displayed or it is not redirecting back. The result can only be seen in the browsers' network tab.
my ajax
$(document).on("click", "#apply", function(){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
type: "get",
url: '/checkstatus',
success: function(store){
if(store == 'confirmed'){
$(".apply_modal").toggleClass("open").show();
$("body").toggleClass("open");
}
},
});
});
and my controller:
public function checkStatus(Request $request)
{
$verify = Auth::user()->verifyAccount();
if($verify == false){
if(session()->has('verify') && session()->get('verify') != '') {
session()->forget('verify');
} else {
session()->flash('verify', 'At first, please update your profile!');
}
}else{
return 'confirmed';
}
}
How can I properly redirect back the user to its main page? The result for now is like this.
Message to the user :
@if(session('verify'))
<div class="complete_box">
<p>{{ session('verify') }}</p>
<a href="{{ url('/mypage') }}">Close</a>
</div>
@endif