Getting the actual URL after a POST which redirected using jquery .ajax()

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:

    type: 'POST',
    url: 'A.html',
    data: '....',
    statusCode: {
        302: function() {
            alert("302"); // this is never called
        200: function() {
    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.


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.

Need Your Help

Debugging menu disabled in NetBeans 7.3

php netbeans xdebug remote-debugging

I have for long used NetBeans and Xdebug successfully to debug my PHP code running on a remote test server. However, after upgrading to NetBeans 7.3, the Debug menu is almost entirely disabled and I

Replacing one character once in string for an n-length string in R

string r text replace

Just a simple problem that has been giving me some issues. I want to take a 20 character string:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.