Permalink
Browse files

Merge pull request #1252 from lift/asc_issue_1252

Add Req.ajax_? function to identify ajax requests.
  • Loading branch information...
2 parents 68715cd + fca7cdf commit 07c008d51735a4b659020d1a04402c126359e0cf David Pollak committed Apr 10, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 web/webkit/src/main/scala/net/liftweb/http/Req.scala
@@ -847,6 +847,18 @@ class Req(val path: ParsePath,
}
/**
+ * Returns true if the X-Requested-With header is set to XMLHttpRequest.
+ *
+ * Most ajax frameworks, including jQuery and Prototype, set this header
+ * when doing any ajax request.
+ */
+ def ajax_? =
+ request.headers.toList.exists { header =>
+ (header.name equalsIgnoreCase "x-requested-with") &&
+ (header.values.exists(_ equalsIgnoreCase "xmlhttprequest"))
+ }
+
+ /**
* Make the servlet session go away
*/
def destroyServletSession() {

0 comments on commit 07c008d

Please sign in to comment.