/    Sign up×
Community /Pin to ProfileBookmark

Hi all,
I haven’t had much luck finding a solution to this so I am hoping someone here can help me. I am making calls using xmlhttprequest which works fine unless there is a redirect. When I hit a 302 redirect what I need to do is get the new location. I have tried getting it from the headers but location isn’t in there so no luck. Since i know which urls are going to be redirected I want to have a ‘lookup’ function that only tries to find the new location for these urls. So by saying that I mean that if I need to use something else besides xmlhttprequest for this function that isn’t a problem (really anything in javascript and not server side reliant). I know the redirect is transparent but I would think there would be some way to get the new location once the redirect is complete.
Thanks for any help.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorApr 21.2011 — Unfortunately a redirect will be captured by the AJAX object not only as a 302, but sometimes as 301 or 278.

You may try something like:

if(xmlhttp.status==302||xmlhttp.status==301||xmlhttp.status==278)
Copy linkTweet thisAlerts:
@rproctor83Apr 21.2011 — Just a quick thought... If you know which pages have the redirect, in your ajax request cant you just point the request to where the redirect lives and not to the page that is redirecting? Im sure you probably can't, otherwise you would just do that... right?
×

Success!

Help @kramttocs spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...