NYCPHP Meetup

NYPHP.org

[nycphp-talk] detecting Ajax calls

David Mintz vtbludgeon at gmail.com
Mon Feb 26 11:45:12 EST 2007


I am wondering what you guys are doing to detect whether your PHP
script is being called via AJAX or --- "regular?" (Do we have a
retronym for that in this brave new Web 2.0 world?).

I know Prototype sends a custom headers, e.g.

        [X-Prototype-Version] => 1.5.0
        [X-Requested-With] => XMLHttpRequest

so looking for those is obviously one way.

I found a discussion somewhere where someone simply suggested adding
something like isAjax=1 as a GET parameter in your Ajax call's URL.
Seems to work.

Thanks.

-- 
David Mintz
http://davidmintz.org/

En Nueva York el tránsito de la belleza a la desolación sucede siempre
expeditivamente, como si el principio universal de máxima eficiencia
hubiera aconsejado la supresión de gradaciones intermedias.

  -- Antonio Muñoz Molina, Ventanas de Manhattan



More information about the talk mailing list