There really isn't an API that exists just for that purpose. Remember, AJAX is also just a simple page load.
One workaround is to check for the HTTP_X_REQUESTED_WITH header. JQuery adds that in on all AJAX requests, so as long as you don't have any modules doing their own AJAX or changing the jQuery AJAX setup, it should work (modules invoking their own AJAX would be a fringe case).
So in hook_init, just go with something like:
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
// Page requested via jQuery - AJAX.
} else {
// Non jQuery-AJAX page request.
}Jamie Holly http://www.intoxination.net http://www.hollyit.netOn 9/24/2012 8:28 PM, Kamal Palei wrote:Hi NancyThanks for help.Initially I thought so and gave a try for _init() hook. It looks it gets called always either it is first time page load, or a page refresh 9F5 in windows env) or even during AJAX events. Even I tried _exit() hook, looks it is also invoked always.I am looking for a hook that gets invoked for first time page load and on page refresh, but should not be invoked during AJAX events.So still searching if any such hooks are available that gets invoked only during first time page load and on page refresh.ThanksKamalNet Cloud SystemsBangalore
On Mon, Sep 24, 2012 at 4:03 PM, Ms. Nancy Wichmann <nan_wich@bellsouth.net> wrote:
http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_init/7Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Kamal Palei
Hi ListI want to know is there any API in D7 is invoked when a page loads for first time or during page refresh/reload.During anyother time that particular api should not be invoked.I have a custom form, and I keep certain variables in $_SESSION. During first time page loads I want to reset the session variables.Also during page refresh (for windows IE F5) also I want to reset session variables.
--
[ Drupal support list | http://lists.drupal.org/ ]
--
[ Drupal support list | http://lists.drupal.org/ ]