http status codes and javascript

O

Oxnard

if I have a javascript function which calls a servlet. The servlet returns
is a HTTP status code of 204 along with a message can a javascript function
be made to parse the message? If so could I have a example.

Thank you
Ox
 
M

Martin Honnen

Oxnard said:
if I have a javascript function which calls a servlet. The servlet returns
is a HTTP status code of 204 along with a message can a javascript function
be made to parse the message? If so could I have a example.

If you already have a function that calls a servlet then you probably
know what to do:
var httpRequest;
if (typeof XMLHttpRequest != 'undefined') {
httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'whatever.jsp', false);
httpRequest.send(null);
alert(httpRequest.status + ' ' + httpRequest.statusText);
}
Should do with Mozilla, Netscape, Safari 1.2.
 
O

Oxnard

Martin Honnen said:
If you already have a function that calls a servlet then you probably
know what to do:
var httpRequest;
if (typeof XMLHttpRequest != 'undefined') {
httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'whatever.jsp', false);
httpRequest.send(null);
alert(httpRequest.status + ' ' + httpRequest.statusText);
}
Should do with Mozilla, Netscape, Safari 1.2.

I guess no IE?
 
M

Martin Honnen

Oxnard wrote:

I guess no IE?

IE on Windows can do it too:
var httpRequest;
if (typeof ActiveXObject != 'undefined') {
httpRequest = new ActiveXObject('Microsoft.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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top