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

[eluser]jcavard[/eluser]
Thank Johan André! It's so simple yet brilliant! neat thanks!

[quote author="Johan André" date="1252421870"]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?[/quote]


Messages In This Thread
Best Practice: Controller that handles multiple access methods (url/uri, ajax, post) - by El Forum - 02-17-2010, 08:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB