XMLHttpRequest and Redirects

R

Ronald Green

Hi all,

I'm trying to write a js function that uses XMLHttpRequest against a
web application.

Sometimes I get a 302, and the XMLHttpRequest automatically
redirects.

What I want to accomplish is either:
1. Don't let it redirect but figure out that it wanted to, and get the
'location' response header.
2. Let it redirect, but know the URL I was redirected to.

The javascript will be running on Internet Explorer 6 if it matters.

Thanks in advance,
R. Green
 
P

Peter Michaux

Hi all,

I'm trying to write a js function that uses XMLHttpRequest against a
web application.

Sometimes I get a 302, and the XMLHttpRequest automatically
redirects.

What I want to accomplish is either:
1. Don't let it redirect but figure out that it wanted to, and get the
'location' response header.
2. Let it redirect, but know the URL I was redirected to.

The javascript will be running on Internet Explorer 6 if it matters.

What Ajax library are you using?

Peter
 
R

Ronald Green

Hi Peter,

I'm not using any library. I just add tiny fragments of js in order to
enhance an existing web application. I'm using this crossplatform
function to get an xmlhttprequest object:

function getHTTPObject()
{
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top