SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Addict dotancohen's Avatar
    Join Date
    Aug 2005
    Location
    Haifa
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "Form.serialize" causing form to post

    I'm following along with Aarron Walter's great AJAX tutorial:
    http://www.sitepoint.com/article/use...d-mailing-list

    I have a four-field form to submit via AJAX, including radio buttons, so I'd like to use Form.serialize instead of building the parameters one by one. When I replace this code:
    Code:
    var pars = 'address=' + escape($F('address'));
    var myAjax = new Ajax.Updater('response', 'ajaxServer.php', {method: 'get', parameters: pars});
    with this:
    Code:
    var myAjax = new Ajax.Updater('response', 'ajaxServer.php', {method: 'get', parameters: Form.serialize(addressForm)});
    I see the text below the form change to "Adding email address..." however the form is submitted via the regular get method to wherever I point the action attribute to. Also, I see that there was no request made on ajaxServer.php as the email address does not get added to the database.

    Why would this be, and how can I avoid it. Specifically, how can I serialize and send the entire form contents?

    Note that I am not using an image as the submit button. I mention this because some otherwise fruitless googling led me to know that using an image as the submit button does cause problems with Form.serialize.

    Thanks in advance.
    Last edited by r937; Dec 18, 2006 at 12:25.
    . Have a question?
    . . What Is Firefox?
    . . . . What Is Open Office?
    . . . . . . What Is What?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •