-
Page Accessed By jQuery or Http?
Here is a little code snippet I have been working with to integrate into the cms I am building with Codeigniter. It is used to determine if the controller is accessed by jQuery ( an ajax request ) or by a normal http request.
/* Access() * returns http if requested by http request * returns ajax if requested by ajax request */ function access() { if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && ( 'XMLHttpRequest' == $_SERVER['HTTP_X_REQUESTED_WITH'] OR 'ActiveXObject' == $_SERVER['HTTP_X_REQUESTED_WITH'] ) ) { // Request identified as ajax request return 'ajax'; } else { // Requested through basic http request return 'http'; } }
Any suggestions and help would be greatly appreciated.>
You can comment over at my blogĀ http://willayers.net/


