Home Forums Front-end Issues generating acf form with ajax Reply To: generating acf form with ajax

  • I’m also struggling to get a working ACF form created by ajax. I’ve tried a couple of the acf.do_action methods that I found but none fully solved the issues. I will say my form has working js validation, and a working select list filter… so it mainly working, and maybe this sample code will help somebody with the issues they are finding. What I can’t get around, is that when I submit the form I land on /wp-admin/admin-ajax.php?updated=true because the ajax doesn’t seem to apply preventDefault() and it acts like a non-ajax form submission.I tried adding my own .submit and using preventDefault but then the form never submits and I see the ajax circle loading endlessly and no data is saved. So using your own preventDefault in a submit handler seems to break the form processing by ACF.

    $.post( devcoreAjax.url, data, function( response ) {
            $('#add-record .modal-body').html( response );
            acf.do_action('append', $('#add-record .modal-body form') );
            acf.do_action('ready', $('#add-record .modal-body form') );
            $('#add-record .modal-body form').submit( function(e) {