XMLHttpRequest

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

    XMLHttpRequest

    function saveText( scroll_list, t_area, listToBeUpdated ) {
    var updated = new Option();
    updated.value = t_area.value;
    updated.text = t_area.text;
    for(var i = 0; i < scroll_list.opt ions.length; i++) {
    if( scroll_list.opt ions[i].selected ) {
    scroll_list.opt ions[scroll_list.sel ectedIndex].text = updated.value;
    scroll_list.opt ions[scroll_list.sel ectedIndex].value= updated.value;
    break;
    }
    }
    var confirmReq;
    var url = "http://mkmxg00/cgi/confirmUpload.p l";
    confirmReq = new ActiveXObject( "Microsoft.XMLH TTP" );
    confirmReq.onre adystatechange = processReqChang e;
    confirmReq.open ( "POST", url, true );
    confirmReq.send ( "" );

    alert( url );
    }
    function processReqChang e() {
    alert( confirmReq.read yState );
    if ( confirmReq.read yState == 4 ) {
    if ( confirmReq.stat us == 200 ) {
    // process the response if successful
    alert( "passed!" );
    }
    }
    else {
    alert( confirmReq.read yState + ", " + confirmReq.stat us );
    }
    }

    my question:
    how do I check what content is being sent over to


    in the XMLHttpRequest?

  • Thomas 'PointedEars' Lahn

    #2
    Re: XMLHttpRequest

    William wrote:
    [color=blue]
    > function saveText( scroll_list, t_area, listToBeUpdated ) {
    > var updated = new Option();
    > updated.value = t_area.value;
    > updated.text = t_area.text;[/color]

    This is nonsense because you do not really use `updated' later.
    [color=blue]
    > for(var i = 0; i < scroll_list.opt ions.length; i++) {
    > if( scroll_list.opt ions[i].selected ) {
    > scroll_list.opt ions[scroll_list.sel ectedIndex].text =
    > updated.value;[/color]

    Assigning t_area.value is equivalent, however you probably wanted
    to assign t_area.text. And are you really sure you want to make all
    selected items the same?
    [color=blue]
    > scroll_list.opt ions[scroll_list.sel ectedIndex].value=
    > updated.value;[/color]

    Assigning t_area.value is equivalent.
    [color=blue]
    > [...]
    > confirmReq.open ( "POST", url, true );
    > [...]
    > confirmReq.send ( "" );
    > [...]
    > my question:
    > how do I check what content is being sent over to
    > http://mkmxg00/cgi/confirmUpload.pl[/color]
    ^^
    Ask in a Perl or CGI-related newsgroup about how to process a (POST)
    request.
    [color=blue]
    > in the XMLHttpRequest?[/color]

    What you pass as the argument of confirmReq.send () becomes the body of the
    request which is evaluated _server-side_. The IXMLHTTPRequest interface
    which provides _client-side_ access to the _response_ of the request does
    not provide a property to access the request body later.


    PointedEars

    Comment

    • William

      #3
      Re: XMLHttpRequest


      On Mon, 23 Jan 2006, Thomas 'PointedEars' Lahn wrote:
      [color=blue]
      > William wrote:
      >[color=green]
      >> function saveText( scroll_list, t_area, listToBeUpdated ) {
      >> var updated = new Option();
      >> updated.value = t_area.value;
      >> updated.text = t_area.text;[/color]
      >
      > This is nonsense because you do not really use `updated' later.
      >[color=green]
      >> for(var i = 0; i < scroll_list.opt ions.length; i++) {
      >> if( scroll_list.opt ions[i].selected ) {
      >> scroll_list.opt ions[scroll_list.sel ectedIndex].text =
      >> updated.value;[/color]
      >
      > Assigning t_area.value is equivalent, however you probably wanted
      > to assign t_area.text. And are you really sure you want to make all
      > selected items the same?
      >[color=green]
      >> scroll_list.opt ions[scroll_list.sel ectedIndex].value=
      >> updated.value;[/color]
      >
      > Assigning t_area.value is equivalent.
      >[color=green]
      >> [...]
      >> confirmReq.open ( "POST", url, true );
      >> [...]
      >> confirmReq.send ( "" );
      >> [...]
      >> my question:
      >> how do I check what content is being sent over to
      >> http://mkmxg00/cgi/confirmUpload.pl[/color]
      > ^^
      > Ask in a Perl or CGI-related newsgroup about how to process a (POST)
      > request.
      >[color=green]
      >> in the XMLHttpRequest?[/color]
      >
      > What you pass as the argument of confirmReq.send () becomes the body of the
      > request which is evaluated _server-side_. The IXMLHTTPRequest interface
      > which provides _client-side_ access to the _response_ of the request does
      > not provide a property to access the request body later.[/color]

      To make a long story short, I was asked by [another person, whose's
      instructions I have to follow] to scrap my code with XMLHttpRequest and
      possibly update the server text file with server side javascript.

      The current process:
      1) web browser displays values of server side text file thru the GUI
      2) the user modifies the values in this text file thru the GUI
      3) such modifications needs to be reflected on the server side text file.

      Assuming I successfully embedded the server side javascript code which
      updates the server side text file; how do I send an HTTP request for a 2nd
      time (i.e. after the user has made the changes), so that my server side
      javascript code actually updates the server side text file?

      This is my first time writing server side javascript, any
      suggestions/references is appreciated.

      (I am currently reading up on:
      http://docs.sun.com/source/816-6411-...rv.htm#1024580)



      Comment

      • Randy Webb

        #4
        Re: XMLHttpRequest

        William said the following on 2/6/2006 11:27 AM:
        [color=blue]
        > To make a long story short, I was asked by [another person, whose's
        > instructions I have to follow] to scrap my code with XMLHttpRequest and
        > possibly update the server text file with server side javascript.
        >
        > The current process:
        > 1) web browser displays values of server side text file thru the GUI
        > 2) the user modifies the values in this text file thru the GUI
        > 3) such modifications needs to be reflected on the server side text file.[/color]

        Place the contents of the text file in a textarea with a submit button.
        Submit the form, let the server update as appropriate.

        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
        Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: XMLHttpRequest

          William wrote:
          [color=blue]
          > On Mon, 23 Jan 2006, Thomas 'PointedEars' Lahn wrote:[color=green]
          >> William wrote:[color=darkred]
          >>> how do I check what content is being sent over to
          >>> http://mkmxg00/cgi/confirmUpload.pl[/color]
          >> ^^
          >> Ask in a Perl or CGI-related newsgroup about how to process a (POST)
          >> request.
          >>[color=darkred]
          >>> in the XMLHttpRequest?[/color]
          >>
          >> What you pass as the argument of confirmReq.send () becomes the body of
          >> the request which is evaluated _server-side_. The IXMLHTTPRequest
          >> interface which provides _client-side_ access to the _response_ of the
          >> request does not provide a property to access the request body later.[/color]
          >
          > To make a long story short, I was asked by [another person, whose's
          > instructions I have to follow] to scrap my code with XMLHttpRequest and
          > possibly update the server text file with server side javascript.[/color]

          In case you misunderstood me saying that (client-side) XMLHTTP requests are
          a Bad Thing, that was not the case.

          Are you saying that you now must implement a JS solution also server-side,
          instead of a Perl solution?
          [color=blue]
          > The current process:
          > 1) web browser displays values of server side text file thru the GUI
          > 2) the user modifies the values in this text file thru the GUI
          > 3) such modifications needs to be reflected on the server side text file.
          >
          > Assuming I successfully embedded the server side javascript code which
          > updates the server side text file; how do I send an HTTP request for a 2nd
          > time (i.e. after the user has made the changes), so that my server side
          > javascript code actually updates the server side text file?[/color]

          I am not sure that you understood the difference between client-side and
          server-side code, and I am not sure if I understood you correctly. For
          one, HTTP requests AIUI you need them to transmit user modifications from
          the client to the server have to be initiated from the client, not from the
          server. And since client-side script code does not change, no matter the
          server-side code (unless the server-side code generates the sending
          client-side one), you just send the same request with different data again.
          The server always sends a response, not a request, to the client; this
          response can of course include any data you want, including the changed
          text file content. So you do not need another request just to show the
          updated data, not matter the programming language used to create the
          response.


          PointedEars

          Comment

          • William

            #6
            Re: XMLHttpRequest

            On Mon, 6 Feb 2006, Thomas 'PointedEars' Lahn wrote:
            [color=blue]
            > William wrote:
            >[color=green]
            >> On Mon, 23 Jan 2006, Thomas 'PointedEars' Lahn wrote:[color=darkred]
            >>> William wrote:
            >>>> how do I check what content is being sent over to
            >>>> http://mkmxg00/cgi/confirmUpload.pl
            >>> ^^
            >>> Ask in a Perl or CGI-related newsgroup about how to process a (POST)
            >>> request.
            >>>
            >>>> in the XMLHttpRequest?
            >>>
            >>> What you pass as the argument of confirmReq.send () becomes the body of
            >>> the request which is evaluated _server-side_. The IXMLHTTPRequest
            >>> interface which provides _client-side_ access to the _response_ of the
            >>> request does not provide a property to access the request body later.[/color]
            >>
            >> To make a long story short, I was asked by [another person, whose's
            >> instructions I have to follow] to scrap my code with XMLHttpRequest and
            >> possibly update the server text file with server side javascript.[/color]
            >
            > In case you misunderstood me saying that (client-side) XMLHTTP requests are
            > a Bad Thing, that was not the case.
            >
            > Are you saying that you now must implement a JS solution also server-side,
            > instead of a Perl solution?[/color]

            I was taking over somebody else's Perl script, and within the Perl script
            also contains javascript code.
            [color=blue]
            >[color=green]
            >> The current process:
            >> 1) web browser displays values of server side text file thru the GUI
            >> 2) the user modifies the values in this text file thru the GUI
            >> 3) such modifications needs to be reflected on the server side text file.
            >>
            >> Assuming I successfully embedded the server side javascript code which
            >> updates the server side text file; how do I send an HTTP request for a 2nd
            >> time (i.e. after the user has made the changes), so that my server side
            >> javascript code actually updates the server side text file?[/color]
            >
            > I am not sure that you understood the difference between client-side and
            > server-side code, and I am not sure if I understood you correctly. For
            > one, HTTP requests AIUI you need them to transmit user modifications from
            > the client to the server have to be initiated from the client, not from the
            > server. And since client-side script code does not change, no matter the
            > server-side code (unless the server-side code generates the sending
            > client-side one), you just send the same request with different data again.[/color]

            The 1st request was sent by the user typing the URL in the location bar of
            his brower.
            How do I send the 2nd HTTP request with the user's click of a button?
            [color=blue]
            > The server always sends a response, not a request, to the client; this
            > response can of course include any data you want, including the changed
            > text file content. So you do not need another request just to show the
            > updated data, not matter the programming language used to create the
            > response.[/color]

            But the user modifications are made after the server send the response
            (i.e. the HTML page that the user uses to update the server side text
            file). So I still need to send a 2nd HTTP request.


            Comment

            • William

              #7
              Re: XMLHttpRequest

              On Mon, 6 Feb 2006, Thomas 'PointedEars' Lahn wrote:
              [color=blue]
              > William wrote:
              >[color=green]
              >> On Mon, 23 Jan 2006, Thomas 'PointedEars' Lahn wrote:[color=darkred]
              >>> William wrote:
              >>>> how do I check what content is being sent over to
              >>>> http://mkmxg00/cgi/confirmUpload.pl
              >>> ^^
              >>> Ask in a Perl or CGI-related newsgroup about how to process a (POST)
              >>> request.
              >>>
              >>>> in the XMLHttpRequest?
              >>>
              >>> What you pass as the argument of confirmReq.send () becomes the body of
              >>> the request which is evaluated _server-side_. The IXMLHTTPRequest
              >>> interface which provides _client-side_ access to the _response_ of the
              >>> request does not provide a property to access the request body later.[/color]
              >>
              >> To make a long story short, I was asked by [another person, whose's
              >> instructions I have to follow] to scrap my code with XMLHttpRequest and
              >> possibly update the server text file with server side javascript.[/color]
              >
              > In case you misunderstood me saying that (client-side) XMLHTTP requests are
              > a Bad Thing, that was not the case.
              >
              > Are you saying that you now must implement a JS solution also server-side,
              > instead of a Perl solution?[/color]

              I was taking over somebody else's Perl script, and within the Perl script
              also contains javascript code.
              [color=blue]
              >[color=green]
              >> The current process:
              >> 1) web browser displays values of server side text file thru the GUI
              >> 2) the user modifies the values in this text file thru the GUI
              >> 3) such modifications needs to be reflected on the server side text file.
              >>
              >> Assuming I successfully embedded the server side javascript code which
              >> updates the server side text file; how do I send an HTTP request for a 2nd
              >> time (i.e. after the user has made the changes), so that my server side
              >> javascript code actually updates the server side text file?[/color]
              >
              > I am not sure that you understood the difference between client-side and
              > server-side code, and I am not sure if I understood you correctly. For
              > one, HTTP requests AIUI you need them to transmit user modifications from
              > the client to the server have to be initiated from the client, not from the
              > server. And since client-side script code does not change, no matter the
              > server-side code (unless the server-side code generates the sending
              > client-side one), you just send the same request with different data again.[/color]

              The 1st request was sent by the user typing the URL in the location bar of
              his brower.
              How do I send the 2nd HTTP request with the user's click of a button?
              [color=blue]
              > The server always sends a response, not a request, to the client; this
              > response can of course include any data you want, including the changed
              > text file content. So you do not need another request just to show the
              > updated data, not matter the programming language used to create the
              > response.[/color]

              But the user modifications are made after the server send the response
              (i.e. the HTML page that the user uses to update the server side text
              file). So I still need to send a 2nd HTTP request.


              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: XMLHttpRequest

                William wrote:
                [color=blue]
                > On Mon, 6 Feb 2006, Thomas 'PointedEars' Lahn wrote:[color=green]
                >> William wrote:[color=darkred]
                >>> On Mon, 23 Jan 2006, Thomas 'PointedEars' Lahn wrote:
                >>>> William wrote:
                >>>>> how do I check what content is being sent over to
                >>>>> http://mkmxg00/cgi/confirmUpload.pl
                >>>> ^^
                >>>> [...]
                >>>>> in the XMLHttpRequest?
                >>>> What you pass as the argument of confirmReq.send () becomes the body of
                >>>> the request which is evaluated _server-side_. The IXMLHTTPRequest
                >>>> interface which provides _client-side_ access to the _response_ of the
                >>>> request does not provide a property to access the request body later.
                >>> To make a long story short, I was asked by [another person, whose's
                >>> instructions I have to follow] to scrap my code with XMLHttpRequest and
                >>> possibly update the server text file with server side javascript.[/color]
                >> [...]
                >> Are you saying that you now must implement a JS solution also
                >> server-side, instead of a Perl solution?[/color]
                >
                > I was taking over somebody else's Perl script, and within the Perl script
                > also contains javascript code.[/color]

                AFAIK a Perl script cannot contain "javascript code". It can generate
                JavaScript code.
                [color=blue]
                > The 1st request was sent by the user typing the URL in the location bar
                > of his brower.[/color]

                I see.
                [color=blue]
                > How do I send the 2nd HTTP request with the user's click of a button?[/color]

                I do not understand this question, considering the code you posted before.
                [color=blue][color=green]
                >> The server always sends a response, not a request, to the client; this
                >> response can of course include any data you want, including the changed
                >> text file content. So you do not need another request just to show the
                >> updated data, not matter the programming language used to create the
                >> response.[/color]
                >
                > But the user modifications are made after the server send the response
                > (i.e. the HTML page that the user uses to update the server side text
                > file). So I still need to send a 2nd HTTP request.[/color]

                And what is the problem, exactly?


                PointedEars

                Comment

                Working...