Welcome Guest, Not a member yet? Register   Sign In
Best Practice: Controller that handles multiple access methods (url/uri, ajax, post)
#3

[eluser]Johan André[/eluser]
I would go for the first approach. It's very slick!

I usually define a constant in application/config/constants.php:

Code:
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');

Then in my controllers (or views):

Code:
if(IS_AJAX)
{
   // Do the ajax magic thing
} else {
   // Do the standard stuff (non-ajax)
}

I guess you extended the useragent-lib since there is no is_ajax()-method built-in?


Messages In This Thread
Best Practice: Controller that handles multiple access methods (url/uri, ajax, post) - by El Forum - 09-08-2009, 03:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB