[lp_client_isAJAX]

Description

Link: [lp_client_isAJAX]
Author: Bil Corry
Category: Client
Version: 8.5.x
License: Public Domain
Posted: Dec. 03, 2007
Updated: Jan. 01, 0001
More by this author...

This tag will return true when the header "X-Requested-With: XMLHttpRequest" is found.  The header is added by jQuery, Prototype and possibly other JavaScript libraries.  Note that this header is easily spoofed.

Parameters

none


Sample Usage

lp_client_isAJAX; // that's it!
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[

define_tag: 'lp_client_isAJAX',
	-description='Returns true if client is an AJAX (XHR) request.',
	-priority='replace';

	// looks for header "X-Requested-With: XMLHttpRequest" added by jQuery and Prototype (and others?)
	// note, can be easily spoofed!

	if: (string_findregexp: client_headers, -find='X-Requested-With:\\s+XMLHttpRequest', -ignorecase)->size;
		return: true;
	/if;
	return: false;

/define_tag;

]

 

Comments

none

Email:


Password:



Newest

Most Popular