I need to have a web page with multiple forms on them. Each form is on a layer. I want to be able to submit any given form without a full page refresh. I would like to be able to have the user submit one form and only have the layer with that particular form reload via ajax. How can I do that?
Subject: Submit one of Multiple Forms on Web Page
Don’t submit the form – copy the form data to an XMLHttp POST request and wait for a 200 status reply.
You need to assemble the form data into “name=value&name2=value2&name3=even+longer+value” URL-encoded format. There are two request header items to set:
req.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
req.setRequestHeader(“Content-length”, params.length);
(where “params” is the URL-encoded form data string), then include the form data as an argument to the send() method:
req.send(params);
If you are using an AJAX library, it should have its own POST methods to handle encoding the data and setting the headers.
Subject: RE: Submit one of Multiple Forms on Web Page
Thank you Stan.
Subject: RE: Submit one of Multiple Forms on Web Page
How can I handle file attachments?
Subject: RE: Submit one of Multiple Forms on Web Page
You’ll need to redesign the form so the attachment is actually done on a separate form in an iframe if you want a static upload control. The problem here is that you can’t programmatically access the user’s file system – and that includes writing a value to an . A more typical AJAXian approach would be to programmatically create the file upload form on user request, and submit the form through an iframe or a separate window using the target attribute.