Submit the form without refreshing the page.
69 votesWordPress Forms
Submit the form without refreshing the page.
69 votesThe tool is very easy to use, customizable, visually appealing and just plain simple.
Craig Elliott (QR2 Marketing)Thanks for the great, quick and perfect support. Ten stars for Formidable, the functions and the support.
Rene L JensenCopyright © 2013 Strategy11, LLC
April 17, 2011 at 3:17 am
If the form is a poll, then it'll be cool to have the results show instantly as well, on the same page, or replacing the space previously occupied by the poll options?
March 12, 2012 at 8:51 am
ok how can i submit a form via ajax?
March 12, 2012 at 9:47 am
It's not yet an option. That's why the feature is on the suggestions list for voting.
April 23, 2012 at 10:30 am
If this feature does get included in a future release please make sure it has options for callbacks and most if not all of there options: http://jquery.malsup.com/form/#options-object
May 6, 2012 at 3:09 am
Is there any eta yet? It would improve the usability of the forms a lot.
May 6, 2012 at 8:05 am
Ya guys lets get this going, we all need it!
May 6, 2012 at 8:44 am
I would pay extra for this as an add on... I think this feature would really complete FormidblePro.
May 7, 2012 at 8:20 am
Ajax submit is currently scheduled for version 1.8.0 This could get pushed up or back depending on the voting in the suggestions section, but it is definitely going to be added in a future release.
May 25, 2012 at 1:22 pm
Hi Formidable Community,
(UPDATE: note, if you're using Formidable 1.06.04 or higher, please read this, then see my update two notes down)
I just came across a case where I needed to be able to submit the form via AJAX. The form is within a modal dialog and I didn't want to have to close the dialog to be able to submit the form. I was able to do it fairly simply. There are two pieces - the javascript, and the php (in WordPress).
JAVASCRIPT:
Let's, for simplicity sake, say your form isn't in a modal dialog, but is rendered on the page itself. You need some Javascript like this:
jQuery(function($){
// First, Define a function to handle the AJAX submission. I'll pass in the Form ID
myAjaxSubmit = function(id){
// Add an input for 'action' - required by the WordPress AJAX API
$form.append($('<input type="text" />').attr({
type: 'hidden',
name: 'action',
value: 'frm_submit_form'
}));
// Note, because we're on the front end, I've had to define ajaxurl manually
// I did it in wp_print_scripts by echoing admin_url('admin-ajax.php')
$.post(ajaxurl,$form.serialize(),function(data){
// Just replace .frm_forms with what's returned
// See the PHP code to understand what gets returned
$form.parents('.frm_forms').html($(data).html());
});
}
// Make it so the submit action is my own function
var $form = $('#my-form-id');
$form.attr('action','javascript:myAjaxSubmit("'+$form.attr('id')+'")');
}
PHP
Within your functions.php, you'll need something like this:
add_action('wp_ajax_frm_submit_form','my_frm_submit_form');
add_action('wp_ajax_nopriv_frm_submit_form','my_frm_submit_form');
function my_frm_submit_form(){
// Will create the entry and echo a message, or the form,
// according to the form's settings
echo FrmEntriesController::show_form($_POST['form_id']);
die();
}
The end result is that the form is submitted via AJAX and the div.frm_forms that contained the original form is replaced by the output generated by Formidable. This setup still works with Formidable's AJAX form validation.
I didn't test it for a complicated form with pages or file uploads. My suspicion is that it would need tweaking, but for a simple form, this just might do your trick.
Cheers
Trevor Mills
topquark.com
------------
Check out Formidable Plus - adds a Table field type to Formidable Pro - topquark.com/extend/plugins/formidable-plus
June 11, 2012 at 10:56 am
We are considering adding Ajax submit for basic forms (forms that don't contain Rich text editor fields or file upload fields) in 1.6.5. Then expanding the functionality to all forms in 1.7.0.
Hopefully getting this basic implementation in place in the next release will address the need for most of you.
June 13, 2012 at 8:05 pm
UPDATE to my earlier solution about doing AJAX submit for forms. That nice elegant one-line PHP solution for creating the form unfortunately does not work any longer in 1.06.04. Sounds like there'll be an official solution in 1.06.05, but if anyone out there is looking for AJAX submit now, I did find a work around. Unfortunately, it's lost some elegance.
1.06.04 introduced a new way of creating the entry from the front end. Unfortunately, this gets bypassed if is_admin() is true (see FrmEntriesController::process_entry). If using the standard WP admin-ajax.php AJAX API, then is_admin() will ALWAYS be true, and there seems no way to create the form as if the user had submitted by boring old POST.
The workaround I found (again, I ain't sayin' it's pretty), was to basically copy the entire FrmEntriesController::process_entry method, sans is_admin(), into a my_process_entry() function and call that from the AJAX function. So, my PHP (for version 1.06.04 of Formidable) now looks like this:
PHP
add_action('wp_ajax_frm_submit_form','my_frm_submit_form');
add_action('wp_ajax_nopriv_frm_submit_form','my_frm_submit_form');
function my_frm_submit_form(){
if (method_exists('FrmEntriesController','process_entry')){
my_process_entry();
// Now the entry has been created, we get back to our elegant one line solution
// for displaying the results
}
echo FrmEntriesController::show_form($_POST['form_id']);
die();
}
function my_process_entry(){
// Copied verbatim from FrmEntriesController::process_method
global $frm_entry, $frm_form, $frm_created_entry, $frm_form_params;
$form = $frm_form->getOne($_POST['form_id']);
if(!$form)
return;
if(!$frm_form_params)
$frm_form_params = array();
$params = FrmEntriesController::get_params($form);
$frm_form_params[$form->id] = $params;
if(!$frm_created_entry)
$frm_created_entry = array();
if(isset($frm_created_entry[$_POST['form_id']]))
return;
$errors = $frm_entry->validate($_POST);
$frm_created_entry[$_POST['form_id']] = array('errors' => $errors);
if( empty($errors) ){
$_POST['frm_skip_cookie'] = 1;
if($params['action'] == 'create'){
if (apply_filters('frm_continue_to_create', true, $_POST['form_id']))
$frm_created_entry[$_POST['form_id']]['entry_id'] = $frm_entry->create( $_POST );
}
do_action('frm_process_entry', $params, $errors, $form);
unset($_POST['frm_skip_cookie']);
}
}
And now the AJAX submit works again.
P.S. - Steve & Steph, how come I can't post nicely formatted code into the Knowledge Base?
July 11, 2012 at 3:32 pm
Is this available yet?
July 12, 2012 at 8:26 am
This isn't available yet. For now, you will need to follow trevor's code to get ajax submit working.
July 12, 2012 at 7:46 pm
Hi Steve, is there an approximate ETA for the release? I have no idea how to implement Trevors code to get the ajax submit working within a wordpress tab.
July 13, 2012 at 9:56 am
We still don't have an ETA on this feature other than to say that we are hoping to implement a basic implementation of the ajax submit in the next release. I am not sure when a beta version will be available for download.
September 26, 2012 at 5:25 pm
Any update on this?
September 27, 2012 at 12:36 pm
This is planned for the next release. No ETA on a beta yet.
September 29, 2012 at 8:24 am
Fantastic. I can't wait for this! +100 for this feature.
The websites I build have responsive web design interfaces hooked up with function and database calls served using Ajax.
We are now web.2012 - your pro forms submitted using Ajax would complete the picture :)
October 15, 2012 at 7:27 pm
So ... finally how the solution is Trevor Mills? Please, can you tell me what files should I modify?
and ...
Where exactly should I change the code?
Thanks!
October 15, 2012 at 11:09 pm
You would probably want to add the Code Trevor Provided in a new plugin or in your theme's functions.php file. Although, I highly recommend doing so on a test environment since his code is untested and unverified. If you aren't very comfortable with PHP, you may want to hire a developer.
October 31, 2012 at 6:54 am
Hi,
I use a registration form done with Formidable and the registration addon. Do I need to include the javascript? If yes, where?
Also, in the JS, there is this line: myAjaxSubmit = function(id){
do I need to replace "id" with the form ID?
November 7, 2012 at 10:24 pm
Another month has passed - any news on this?
.....desperate for this - I have to hand code a solution for this today :(
November 30, 2012 at 2:51 pm
Another vote for Ajax submit.... Make it so
December 17, 2012 at 2:29 pm
I agree, ajax submit would be awesome.
January 9, 2013 at 10:48 pm
Any news on this - still waiting.... ?!
January 10, 2013 at 10:01 am
We still haven't started on this feature. There are other features and enhancements that are higher priority than this, and we have no ETA on when it will be available. If you need this functionality now, you will need to hire a developer to add this functionality to your site.
January 21, 2013 at 9:17 am
This would be great to be able to use the first part of a form to match entries from another form, then a user could select the entry that was most appropriate to them and the continue on to complete the form.
January 21, 2013 at 9:32 am
@mytoura, that's not really related to ajax submit. This one looks closer to what you are after:
http://formidablepro.com/help-desk/load-entry-data/
February 2, 2013 at 10:14 am
So is there any way of dropping my fomidable form in a modal without AJAX submit?
February 2, 2013 at 11:11 am
@eric, Yes this can still be done. See: http://formidablepro.com/help-desk/form-pop-up-window-function/ and http://formidablepro.com/help-desk/lightbox-feature/
February 12, 2013 at 6:12 pm
Hope this feature is implemented at some point. I require this feature for some parts of my website. I've held it off until some official implementation of ajax is put into formidable.
February 12, 2013 at 8:08 pm
Ajax submit is included in the version of Formidable Pro currently in Beta. You are welcome to download the beta or wait until it is officially released.
The only limitation of the current version of Ajax submit is with file upload fields. It will work with all field types except file upload fields.
February 20, 2013 at 11:08 am
Thats great news!
Can you give us an estimation of when it will be released offically?
Thanks in advance.
February 20, 2013 at 5:23 pm
Soon. We don't know exactly when as that depends on how many users start using the Beta and what Bugs get uncovered.
Topic closed.