Is it possible to restrict a Symfony 2 route for XHR requests only? I want to declare routes, which are only accessible via AJAX.
I do not want to put some extra lines into each AJAX-specific-actions like that:
if ($request->isXmlHttpRequest()) {
// do something
} else {
// do something else
}
I want to define:
- one rule for AJAX requests
- one rule for GET/POST requests to the same URL
in order to get around having conditions like above.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…