Lasso Soft Inc. > Home

[lp_client_isAJAX]

Linklp_client_isAJAX
AuthorBil Corry
CategoryClient
Version8.5.x
LicensePublic Domain
Posted03 Dec 2007
Updated03 Dec 2007
More by this author...

Description

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.

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.

[

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

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft