Posted By

Alexw on 07/03/09


Tagged

http ajax php cgi


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Alexw
heinz1959


isAjax()


 / Published in: PHP
 

Returns true is the request was made with one of the Ajax libraries that adds the "X-Reqested-With" HTTP header, for example: jQuery.

  1. function isAjax ()
  2. {
  3. if (
  4. isset($_SERVER['HTTP_X_REQUESTED_WITH'])
  5. && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest")
  6. return true;
  7. return false;
  8. }

Report this snippet  

You need to login to post a comment.