Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Accessing form fields in PHP via ajax

    I have a page where I collect information in fields, radio buttons, checkboxes, etc. As the use changes the values in the form, the contents of the page are updated dynamically... things are working pretty well so far.

    However, passing the relevant values from JavaScript to the php page(s) - e.g.,
    var full_url = url + query;
    var request = createXMLHttpRequest();
    request.open("GET", full_url, true);
    is becoming tedious... the query can get pretty long.

    Is there a simple way for my php pages to access the form values? I naively changed the request.open from GET to POST but that did not seem to work...

    I'm sure that this has been asked before... Can someone point me to a link?

    TIA

    Al

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    if you're ok with using a framework, prototype has some awesome tools

    http://www.prototypejs.org/api/form/serialize

    ^ that will take the form of your choice and turn it into a string for your ajax request. prototype has a lot of other toys for handling these things too.


  •  

    Tags for this Thread

    Posting Permissions

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