I have a Symfony app where the admin role have buttons that can activate/deactivate users.
public function activeActionSchedule(Request $request, $id , User $user)
{
$em = $this->getDoctrine()->getEntityManager();
if($user->getIsActive() == 1){
$user->setIsActive(0);
} else {
$user->setIsActive(1);
}
$em->persist($user);
$em->flush();
return $this->redirectToRoute('view', array('id' => $user->getLoanId()->getId()));
}
When I click that button it goes to this route, and after execution it refreshes completely the page (redirect). It's here a way how to not return nothing that will refresh/redirect to another page, so it will work just like Ajax call? If it's not possible and it's necessary to use Ajax, I think anyway I need to modify the response, how?