Welcome Guest, Not a member yet? Register   Sign In
How to detect a Ajax request?
#10

[eluser]alexsancho[/eluser]
This code works with all major javascript frameworks, and it's easy to include in any ajax library, you only need to send this header with any ajax call.

I've extended the input library to add a function that return TRUE, FALSE,

Code:
function isAjax() {
    return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']=="XMLHttpRequest");
}

in this way we can check ajax request with

Code:
if($this->input->isAjax()) {
        ...
    }


Messages In This Thread
How to detect a Ajax request? - by El Forum - 08-26-2007, 10:19 AM
How to detect a Ajax request? - by El Forum - 08-26-2007, 10:56 AM
How to detect a Ajax request? - by El Forum - 08-26-2007, 12:55 PM
How to detect a Ajax request? - by El Forum - 08-26-2007, 01:15 PM
How to detect a Ajax request? - by El Forum - 08-26-2007, 03:33 PM
How to detect a Ajax request? - by El Forum - 08-26-2007, 03:42 PM
How to detect a Ajax request? - by El Forum - 08-26-2007, 03:50 PM
How to detect a Ajax request? - by El Forum - 08-26-2007, 03:52 PM
How to detect a Ajax request? - by El Forum - 08-27-2007, 06:09 AM
How to detect a Ajax request? - by El Forum - 08-27-2007, 07:43 AM
How to detect a Ajax request? - by El Forum - 01-09-2009, 10:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB