Post data to server from javascript on client side

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

    #1

    Post data to server from javascript on client side

    Hello everyone,

    I have a few values and variables that I want to post to a server
    (without using a SUBMIT button). Is there a way to post data from
    within javascript - do sockets or connections have to be open for this
    to work?

    Any help, hints or advice is appreciated :-)

    Kindest Regards.

  • Java script Dude

    #2
    Re: Post data to server from javascript on client side

    If you can stick with Mozilla support only, you could use JS Connect.[color=blue]
    >From what I remember, it allowed for direct connection between[/color]
    JavaScript on a client to an app on the Server.

    Personally I've never tried using JS Connect as I, unfortunately, must
    support IE as the primary browser.
    JsD
    [Happily building IE deployed apps with Mozilla]

    Comment

    • Tim Williams

      #3
      Re: Post data to server from javascript on client side

      Do you really mean POST (as opposed to GET), or just "send".

      To send values via a GET you could create an image in js and assign a
      URL containing your (suitably encoded) values to its src.
      Or use the (XML)HTTP request object (activex in IE and buil-in in NS
      IIRC) to GET or POST.



      Or use remote scripting (google for this and you should find at least
      one relatively cross-browser implementation) .

      Tim.



      "milkyway" <d0mufasa@hotma il.com> wrote in message
      news:1106002049 .051447.47650@z 14g2000cwz.goog legroups.com...[color=blue]
      > Hello everyone,
      >
      > I have a few values and variables that I want to post to a server
      > (without using a SUBMIT button). Is there a way to post data from
      > within javascript - do sockets or connections have to be open for
      > this
      > to work?
      >
      > Any help, hints or advice is appreciated :-)
      >
      > Kindest Regards.
      >[/color]


      Comment

      • www.1-script.com

        #4
        Re: Post data to server from javascript on client side


        milkyway wrote:

        [color=blue]
        > Hello everyone,[/color]
        [color=blue]
        > I have a few values and variables that I want to post to a server
        > (without using a SUBMIT button). Is there a way to post data from
        > within javascript - do sockets or connections have to be open for this
        > to work?[/color]
        [color=blue]
        > Any help, hints or advice is appreciated :-)[/color]
        [color=blue]
        > Kindest Regards.[/color]

        What prevents you from having a (named) form on your page with properly
        setup action="http://yourhost.com/yourreceiving.c gi" in the tag. Then
        populate the input field values manually or from JS and then use
        yourformname.su bmit(); when you're done?
        If you want the original page to stay on the same URL, you can just make
        the form open a new window, which, when fully loaded, will close itself.
        Gotta be careful with popups after the Win XP SP2 though - could easily be
        disabled on the customer's PC. Can always submit the original page and
        then redirect it back if popup is a problem.


        Sincerely,
        Dmitri

        Check out my CGI scripts installation offer
        -------------------------------------




        ##-----------------------------------------------#
        Article posted with Web Developer's USENET Archiv

        no-spam read and post WWW interface to your favorite newsgroup -
        comp.lang.javas cript,comp.info systems.www.authoring.html - messages and counting
        ##-----------------------------------------------##

        Comment

        • milkyway

          #5
          Re: Post data to server from javascript on client side

          Hello again everybody,

          Grant asked me to say what my goal is soooo here it goes (actually, I
          thought I had posted it a short while ago but it does not look like my
          new info made it out to the network).

          Basically, I have a table on the HTML page that one can add rows to
          dynamically. After rows are added, I want to save the contents of the
          table to the server and eventually to be saved to a database. I have
          found that by using the statements below, I am able to get the data out
          of the cell:

          myrow=mytablebo dy.getElementsB yTagName("tr"). item(row);
          mycel=myrow.get ElementsByTagNa me("td").item(c olumn);
          data=mycel.chil dNodes.item(0). data;

          Now I just need to send it to the server. I was doing further search on
          the net and saw that hidden fields can be used - but - how does one add
          hidden fields (dynamically) to a form? Also, in addition to the "hidden
          fields" solution, there is a one that uses a "query string" - at least
          that is what they say on this page here:

          http://forums.devshed.com/archive/t-16003

          Which approach is better - hidden fields or query string and (as asked
          above) if hidden fields are better, how does one add them dynamically
          to a form?

          Regards,
          Milkyway

          Comment

          • milkyway

            #6
            Re: Post data to server from javascript on client side

            Hi once more,

            Here is a link where one is adding the parameters to an action
            attribute of a form.

            Regards.




            milkyway wrote:[color=blue]
            > Hello again everybody,
            >
            > Grant asked me to say what my goal is soooo here it goes (actually, I
            > thought I had posted it a short while ago but it does not look like[/color]
            my[color=blue]
            > new info made it out to the network).
            >
            > Basically, I have a table on the HTML page that one can add rows to
            > dynamically. After rows are added, I want to save the contents of the
            > table to the server and eventually to be saved to a database. I have
            > found that by using the statements below, I am able to get the data[/color]
            out[color=blue]
            > of the cell:
            >
            > myrow=mytablebo dy.getElementsB yTagName("tr"). item(row);
            > mycel=myrow.get ElementsByTagNa me("td").item(c olumn);
            > data=mycel.chil dNodes.item(0). data;
            >
            > Now I just need to send it to the server. I was doing further search[/color]
            on[color=blue]
            > the net and saw that hidden fields can be used - but - how does one[/color]
            add[color=blue]
            > hidden fields (dynamically) to a form? Also, in addition to the[/color]
            "hidden[color=blue]
            > fields" solution, there is a one that uses a "query string" - at[/color]
            least[color=blue]
            > that is what they say on this page here:
            >
            > http://forums.devshed.com/archive/t-16003
            >
            > Which approach is better - hidden fields or query string and (as[/color]
            asked[color=blue]
            > above) if hidden fields are better, how does one add them dynamically
            > to a form?
            >
            > Regards,
            > Milkyway[/color]

            Comment

            Working...