I'm writing the controller part of MVC for a home-grown framework at the moment. I've decided I want to have separate controller actions for handling Ajax request than to normal ones.
I have a request builder object that constructs the request object, this object has to set a property "isAjax" on the request. What can I check for to set such a property?
Detecting if a request is Ajax
Moderator: General Moderators
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
CoderGoblin wrote:I think the Jscript and Prototype libraries both set a header but I am not 100% certain. You may want to look at what they do.
Code: Select all
if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
define('IS_AJAX',true);
}- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact: