freelance84 Posted July 7, 2011 Share Posted July 7, 2011 I have a rather complicated form with a combination of hidden fields, radio buttons and check boxes. The quantity of form elements is decided by the user, elements are removed and added with js and jquery. At present the user finalizes the content on their form and hits a submit button which send the form data in the traditional way back to the server in the $_POST array. The php processes the data and produces results accordingly. Nothing too unusual there. However, the user may wish to hit the same submit button several times to generate different results: Each time the form is submitted the whole html page has to be reloaded. Whilst trying to optimize the site I have decided to eliminate this complete page refresh in favour for AJAX the only bit of data the user is interested in is only 1 tenth the entire content of the page... So: I found (i think it may have been from a previous post on here this: http://pietschsoft.com/post/2006/06/01/Javascript-Loop-through-all-elements-in-a-form.aspx This is great, i could loop through all the elements of the form with a js function, filter accordingly, then $_POST the data with AJAX to the processor which in turn echo's the results... This does however feel like there is an extra and unnecessary step. Is there a more efficient way? Is there any way of simply replicating the browsers form submit with AJAX. ie simply sending the whole form in the same way that the browser does? Or am i barking up the wrong tree? Is the only way to loop through all the elements? Quote Link to comment https://forums.phpfreaks.com/topic/241312-dynamic-form-ajax-submit/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.