Posted By

supermauerbros on 03/28/11


Tagged

ajax php header jquery


Versions (?)

Test for AJAX Header in PHP


 / Published in: PHP
 

URL: http://davidwalsh.name/detect-ajax

  1. /* decide what the content should be up here .... */
  2. $content = get_content(); //generic function;
  3.  
  4. /* AJAX check */
  5. if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
  6. /* special ajax here */
  7. die($content);
  8. }
  9.  
  10. /* not ajax, do more.... */

Report this snippet  

You need to login to post a comment.