You can use this method to check if the controller has been called using an AJAX request or not. This may allow you to do some adaptive rendering. For example, if it is not an AJAX request that returns HTML, if it is an AJAX request, return JSON.
source
share