Let's consider a scenario like below:
- User selects filter button which create a AJAX call to a symfony2 controller and return the result in JSON format.
- User select some other links and system will redirect him to the page
- User select browser Back button.
- User will see JSON response, but he should see the original page.
My controller look like below :
/**
*
*
* @Route("/ajax", name="ajax_route" , options={"expose"=true})
* @Template()
*/
public function someAction()
{
$request = $this->getRequest();
$json = array( );
if($request->isXmlHttpRequest())
{
$res = json_encode($json);
return new Response($res , 200 , array( 'Content-Type' => 'application/json' ));
}
return array( );
}
In other words, if user press back button the if($request->isXmlHttpRequest()) returns true which is not the result I am looking for. Is it a normal behavior or what ?