checking on the server to see if a call is from Ajax or not

2 Nov
function isAjax() {?? ?? return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ?? ?? ?? ?? ??($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));}if(isAjax()) { ?? ?? // do something} else {?? ?? // do something else, or nothing}

Advertisements

One Response to “checking on the server to see if a call is from Ajax or not”

  1. rakesh314 November 2, 2009 at 6:39 pm #

    This only works if the client sends the header. This makes it library dependent. Not necessarily the best technique.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: