Problem with XMLHTTP request. Please help! (long)

R

Robert Cholewa

Hi

I'm using Microsoft.XMLHTTP object from within JavaScript HTA
application (or WScript).
Object is set to use asynchronous mode as following:

---------
var oXMLRequest = new ActiveXObject("Microsoft.XMLHTTP");
var sURL = "http://www.url.com/page.jsp";
var sParams = "param1=value";

function send()
{
oXMLRequest.Open("POST", sURL, true);
oXMLRequest.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
oXMLRequest.onreadystatechange=sendHandler;
oXMLRequest.Send(sParams );
}

function sendHandler()
{
alert(oXMLRequest.readyState);
}
---------

The point is, destination page is doing redirect sending back '302
Moved Temporarily' status.
Above code runs well if redirection is made to the same host as
specified in 'sURL' variable.
But in case target for the redirection is different, status number '4'
is never displayed.
Statuses 1, 2 and 3 are displayed in both cases.

Below is listening in case the code works:

---------
POST /page.jsp HTTP/1.0
Accept: */*
Accept-Language: pl
Referer: app.hta
Content-Type: application/x-www-form-urlencoded
Connection: Close
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.1.4322)
Host: www.url.com
Content-Length: xx
Pragma: no-cache

Data found after header end:

param1=value


HTTP/1.1 302 Moved Temporarily
Server: Netscape-Enterprise/4.1
Date: Tue, 23 Nov 2004 20:18:39 GMT
Location: http://www.url.com/log.jsp?error=2
Content-length: 0
Content-Type: text/vnd.wap.wml
Info: Manualy changed
Connection: close



GET /log.jsp?error=2 HTTP/1.0
Accept: */*
Accept-Language: pl
Referer: app.hta
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.1.4322)
Host: www.url.com
Connection: Close


HTTP/1.1 200 OK
Server: Netscape-Enterprise/4.1
Date: Tue, 23 Nov 2004 20:18:40 GMT
Content-Type: text/html; charset=iso-8859-2
Set-Cookie: JSESSIONID=Bjbg8YrHXDpvPhJs1M18PVj59sn2kSvLBSly7aeGZqokoHEfe4G1!1374542120!-1062708702!7001!-1;
path=/
Connection: close

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
....
---------


and here it does not:


---------
POST /page.jsp HTTP/1.0
Accept: */*
Accept-Language: pl
Referer: app.hta
Content-Type: application/x-www-form-urlencoded
Connection: Close
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.1.4322)
Host: www.url.com
Content-Length: xx
Pragma: no-cache

Data found after header end:

param1=value


HTTP/1.1 302 Moved Temporarily
Server: Netscape-Enterprise/4.1
Date: Tue, 23 Nov 2004 20:21:41 GMT
Location: http://www.new_url.com/log.jsp?error=2
Content-length: 0
Content-Type: text/vnd.wap.wml
Info: Manualy changed
Connection: close



GET /log.jsp?error=2 HTTP/1.0
Accept: */*
Accept-Language: pl
Referer: app.hta
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.1.4322)
Host: www.new_url.com
Connection: Close


HTTP/1.1 200 OK
Date: Tue, 23 Nov 2004 20:21:42 GMT
Server: Apache/1.3.33 (Unix) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
....
---------


Any help would be appreciated?

Greetings,
Rob
 
B

Bradley Baumann

Seems to be something server-side. I don't see anything wrong with your
JavaScript code.
 

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,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top