Posting from form to server using AJAX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Johnson
    New Member
    • Aug 2007
    • 5

    Posting from form to server using AJAX

    I'm an experienced web/CGI programmer, but new to ajax.
    I'd like to review some examples of how to post data from a
    form to server using AJAX. I have already created some examples
    successfully that read data from a server to a form using
    'get' as the first argument to the open() method

    Also:
    I have a client who wants to post some very large forms using
    AJAX, but I'm concerned about the limits of the size of the
    argument to the send() method of an ajax object.
    I presume that I will need to write javascript code that 'walks'
    thru form elements and concatenates a string in the
    follow format var1=val1&var2= val2...... escaping as necessary.

    My concern is that the form may have as many as 600 fields!
    I'd welcome both simple examples to get started and comments
    on whether there is a limit on the size of the send() method argument string.
    Thanks
    Tim
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN!

    Here's an example to get you started.

    I'm not sure about the limits. Give it a try and see how it goes.

    Comment

    • Dasty
      Recognized Expert New Member
      • Nov 2007
      • 101

      #3
      You should care about size limits only with sending "get" requests. Sending "post" requests are not limited by protocol spec. The only limit I can see is javascript string limit, but not technology itself. Anyway 600 items are far from limits, so dont worry. (I was using strings up to 100Mb long when I was tring memory leeks in IE)

      If you want to send such a huge forms, you should write function to serialize them into string, like "AjaxRequest.se rializeForm" one here: http://www.ajaxtoolbox.com/request/source.php

      Check it out ...

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by Dasty
        If you want to send such a huge forms, you should write function to serialize them into string, like "AjaxRequest.se rializeForm" one here: http://www.ajaxtoolbox.com/request/source.php
        Yes, a nice and compact function and using encodeURICompon ent instead of escape.

        Comment

        • Tim Johnson
          New Member
          • Aug 2007
          • 5

          #5
          Thanks to all for the replies. This is going to get me started.
          I will go over all code examples later today.
          :-)And unless I get *really* lucky, you will hear from
          me again.
          Cheers
          Tim

          Comment

          • Tim Johnson
            New Member
            • Aug 2007
            • 5

            #6
            Just wanted to add:
            Documentation and examples for this are:
            Here
            Tim

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Originally posted by Tim Johnson
              Thanks to all for the replies. This is going to get me started.
              I will go over all code examples later today.
              :-)And unless I get *really* lucky, you will hear from
              me again.
              OK, no problem. Let us know how you get along.

              Comment

              • Tim Johnson
                New Member
                • Aug 2007
                • 5

                #8
                It looks like AjaxRequest.js is an industrial-strength module and
                is just what I need.
                But I have a related question:
                I think it is going to be more productive to have a custom
                server application running on the server side.
                I'm a python programmer (among other PLs) and I'm looking at
                the documentation for the CGIHTTPServer module, which would
                do most of the heavy lifting for such a customer server.

                There is documentation for this module Here
                and there are references there to an inability to handle redirects
                via http 302. Could this be a problem?
                thanks
                Tim

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Originally posted by Tim Johnson
                  There is documentation for this module Here
                  and there are references there to an inability to handle redirects
                  via http 302. Could this be a problem?
                  I think this question would be better suited to the Python forum.

                  Comment

                  • Tim Johnson
                    New Member
                    • Aug 2007
                    • 5

                    #10
                    You're correct. Poorly posed question....
                    I guess my question should have been
                    What's http 302?
                    And how relevant is it to ajax?
                    and I can google that.
                    Thanks
                    Tim

                    Comment

                    Working...