Is it possible to have a form submit normally if button X is pushed
and do an AJAX call if button Y is pushed?
My use case:
I'm letting users do some customizations and I want a preview button
and a save button. Hitting preview submits the current form values
as an AJAX call and the returned javascript generates a preview. When
they are happy with the results they hit save which should just submit
the form normally.
I guess another option would be to have a separate form for the AJAX
preview function that copies all the values from the main form.
Is it possible to have a form submit normally if button X is pushed
and do an AJAX call if button Y is pushed?
My use case:
I'm letting users do some customizations and I want a preview button
and a save button. Hitting preview submits the current form values
as an AJAX call and the returned javascript generates a preview. When
they are happy with the results they hit save which should just submit
the form normally.
I guess another option would be to have a separate form for the AJAX
preview function that copies all the values from the main form.
Any pointers?
Use jQuery's .post and .serialize methods to grab the data and submit it via ajax... then do whatever you want with it on the backend...