http status codes and javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oxnard

    #1

    http status codes and javascript

    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


  • Martin Honnen

    #2
    Re: http status codes and javascript



    Oxnard wrote:
    [color=blue]
    > 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.[/color]

    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.ope n('GET', 'whatever.jsp', false);
    httpRequest.sen d(null);
    alert(httpReque st.status + ' ' + httpRequest.sta tusText);
    }
    Should do with Mozilla, Netscape, Safari 1.2.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • Oxnard

      #3
      Re: http status codes and javascript


      "Martin Honnen" <mahotrash@yaho o.de> wrote in message
      news:417a8155$0 $22619$9b4e6d93 @newsread4.arco r-online.net...[color=blue]
      >
      >
      > Oxnard wrote:
      >[color=green]
      > > if I have a javascript function which calls a servlet. The servlet[/color][/color]
      returns[color=blue][color=green]
      > > is a HTTP status code of 204 along with a message can a javascript[/color][/color]
      function[color=blue][color=green]
      > > be made to parse the message? If so could I have a example.[/color]
      >
      > 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.ope n('GET', 'whatever.jsp', false);
      > httpRequest.sen d(null);
      > alert(httpReque st.status + ' ' + httpRequest.sta tusText);
      > }
      > Should do with Mozilla, Netscape, Safari 1.2.
      >
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/[/color]

      I guess no IE?


      Comment

      • Martin Honnen

        #4
        Re: http status codes and javascript



        Oxnard wrote:

        [color=blue]
        > I guess no IE?[/color]

        IE on Windows can do it too:
        var httpRequest;
        if (typeof ActiveXObject != 'undefined') {
        httpRequest = new ActiveXObject(' Microsoft.XMLHT TP');
        ...
        }

        --

        Martin Honnen
        http://JavaScript.FAQTs.com/

        Comment

        Working...