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 5972087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:36:31+00:00 2026-05-22T20:36:31+00:00

I am following the PRG (Post-Redirect-Get) pattern in my web application, and use something

  • 0

I am following the PRG (Post-Redirect-Get) pattern in my web application, and use something like the following for doing most of my POSTs:

$.ajax({
    type: 'POST',
    url: 'A.html',
    data: '....',
    statusCode: {
        302: function() {
            alert("302"); // this is never called
        },
        200: function() {
            alert("200");
        },
    },
    success: function (data, textstatus) {
        alert('You are now at URL: ' + ??);
    },
    error: function (data) {
    },
    complete: function (jqXHR, textstatus) {
        alert('You are now at URL: ' + ??);
    },
});

I need to get the URL AFTER any redirection has occurred, i.e. the URL of the final GET that the .ajax() function called. For example a POST to A.html may redirect to either B.html or C.html (always via 302’s). How do I get the final URL?

I am using jquery 1.5.1, and using a proxy have witnessed that jquery is silently following the redirects – which I am happy with. I don’t care about any of the URLs which responded with 302’s – I would just like to know the URL of the final request at the time that .ajax()’s “success:” or “complete:” hooks are fired.

  • 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-22T20:36:32+00:00Added an answer on May 22, 2026 at 8:36 pm

    I finally solved this issue by adding an additional header into all my responses (eg “X-MYAPP-PATH: /Admin/Index”).

    My javascript could thus be changed to the following:

    success: function (data, textstatus, xhrreq) {
        alert('You are now at URL: ' + xhrreq.getResponseHeader("X-MYAPP-PATH"));
    },
    

    I still believe however that jquery should be able to give me the current URL, so I consider this a hack.

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

Sidebar

Related Questions

I want to learn and use Drupal or Django for the following: dynamic web
Following this post which I posted some time ago, I now get the same
I'm new to post/redirect/get. I'm coding up the first real site that led me
Following this post and the other posts that it links to, I have successfully
Following on from my recent question on Large, Complex Objects as a Web Service
Following this question: Good crash reporting library in c# Is there any library like
Following this question I get a message on the retrieved page that Your browser
following the instructions here http://wiki.apache.org/couchdb/ExternalProcesses this is what I get { * error: {{badarg,[{erlang,port_command,
Following method is accepted if I set UIColor like: [tabBarController.tabBar setSelectedImageTintColor:[UIColor greenColor]]; However I
Following on from an earlier question I'm trying to get multiple (widgets or in

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.