Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7176723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:34:01+00:00 2026-05-28T16:34:01+00:00

actually the question is as simple as the topic says. Is there any way

  • 0

actually the question is as simple as the topic says. Is there any way to give different ajax handlers a higher/lower priority (which means here, that they will fire earlier) ?

What do I mean? Well, I have to deal with a fairly huge web-app. Tons of Ajax requests are fired in different modules. Now, my goal is to implement a simple session-timeout mechanism. Each request sends the current session-id as parameter, if the session-id is not valid anymore, my backend script returns the request with a custom response-header set (value is a uri).

So I’m basically going like this

window.jQuery && jQuery( document ).ajaxComplete(function( event, xhr, settings ) {
    var redirectto = xhr.getResponseHeader( 'new_ajax_location' );
    if( redirectto ) {
        location.href = redirectto;
    }
});

This does work like a charm of course, but my problem is that this global ajax event actually needs to get fired first 100% of the time, which is not the case. Some of those original ajax-requests handlers will throw an error because of missing or unexpected data, in that case, the global handler never gets executed.

Now, I’d be kinda happy if I wouldn’t need to go through every single request handler and make it failsafe for invalid session data responses. I’d much more prefer to do the job at one particular place. But how can I make sure my global handler will get executed first ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:34:02+00:00Added an answer on May 28, 2026 at 4:34 pm

    If I understand you correctly, you want to add your own callback to json requests everywhere. You could use the ajaxPrefilter hook.

        $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
            options.complete = function (jqXHR2, settings) {
                var redirectto = jqXHR2.getResponseHeader( 'new_ajax_location' );
                if( redirectto ) {
                    location.href = redirectto;
                }
            }
        });
    

    You can also change the options there to add the session-id to the request params.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Another simple question : is there any way to tell flex to prefer a
There are actually 2 question i want to cover in this topic. 1) Is
Actually a simple question, but I wasn't able to find any good conclusive answer.
Simple question - what does this actually do? var oq = (ObjectQuery<TEntity>)L2EQuery; return ExecuteFirstorDefault<TEntity>(oq,
i have a very simple question, actually this is not the question, this is
The Question actually says it all. The reason behind this question is I am
Hi actually this is a simple question but just came up out of the
I have a probably pretty simple question but I am still not sure! Actually
Actually the question is simple. I don't know what to add to the title
Actually my question is quite simple: I have a string like: 101222_1_1_ab ; I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.