Posted By

joshuascott94 on 08/28/10


Tagged

http ajax header XMLHttpRequest request x-requested-with


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

seloh77
mikael12
wirenaught


Check if request is AJAX request


 / Published in: PHP
 

URL: http://www.gmarwaha.com/blog/category/client-side/javascript/

Quick and easy way to determine if the HTTP request is an AJAX call or a standard call. Supports the notion of Unobtrusive JavaScript.

  1. function isAjax() {
  2. return (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
  3. &&
  4. ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
  5. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: buzzknow on September 17, 2010

nice...thanks :)

You need to login to post a comment.