mtre...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed 382e941

Fixed #6616 -- Added an is_ajax() method to HttpRequest that uses the de facto
standard header for detecting an XmlHttpRequest call. Thanks, Daniel Lindsley.

  • Participants
  • Parent commits fff2063

Comments (0)

Files changed (3)
     Mikko Hellsing <>
+    Daniel Lindsley <>
     Orestis Markou <>
     Slawek Mikula <slawek dot mikula at gmail dot com>

File django/http/

     def is_secure(self):
         return os.environ.get("HTTPS") == "on"
+    def is_ajax(self):
+        return self.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'
     def _set_encoding(self, val):
         Sets the encoding used for GET/POST accesses. If the GET or POST

File docs/request_response.txt

    Returns ``True`` if the request is secure; that is, if it was made with
+   **New in Django development version**
+   Returns ``True`` if the request was made via an XMLHttpRequest by checking
+   the ``HTTP_X_REQUESTED_WITH`` header for the string *'XMLHttpRequest'*. The
+   following major Javascript libraries all send this header:
+   * jQuery
+   * Dojo
+   * MochiKit
+   * MooTools
+   * Prototype
+   * YUI
+   If you write your own XMLHttpRequest call (on the browser side), you will
+   have to set this header manually to use this method.
 QueryDict objects