I am looking to submit my forms via ajax using a .submit jquery handler and then calling $.post to submit the form data to a custom ajax page which will call my ajax form handler which will post the data to drupal_execute then return true (or false with errors) if the form is successful. Then I can prevent the page from refreshing and call some more jquery magic after the form is submitted.

My question is, is this a bad idea for any reason? It seems like magic to me, but I don't want to develop anything that is frowned upon because of best practices.

Comments

jlaaker’s picture

Then you can prosess all the magic you want without page reload. And if something fail, you just cancel the submittion. In this validate function you also have access to all the data submitted by $form_state['values']['fieldname'] or you can make a query to the db.

mrconnerton’s picture

the problem is that I will have no way to execute a second jquery method after the form is submitted if I do it in the form_validate (or _submit)