[eluser]WanWizard[/eluser]
I have a helper to check for ajax calls:
Code:
/**
* is_ajax_call
*
* Determines if the current page request is done through an AJAX call
*
* @access public
* @param void
* @return boolean
*/
if ( ! function_exists('is_ajax_call'))
{
function is_ajax_call()
{
if ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest")
{
// we should do more checks here, for now this is it...
return TRUE;
}
else
{
return FALSE;
}
}
}
For URL's that return JSON instead of HTML, I check in the controller method() if it's an ajax call, and if not, redirect to a 404 page.