View Full Version : Accessing form fields in PHP via ajax

10-01-2008, 03:48 PM
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?



10-01-2008, 04:26 PM
if you're ok with using a framework, prototype has some awesome tools


^ 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.