CRED does not support AJAX Loading or Submit of it's forms yet.
This is under development and will be shipped din one of our future releases, but for now, every Custom Code that allows you to load CRED with AJAX, is provided as is and not supported or troubleshooted.
I myself created a workaround some time ago that works very fine, also with the CRED API - note that I never actually tested validation API; but it should also work in that case.
CRED Submitting Forms via AJAX is possible with this slight JS script. Note that this does ONLY submit the form and NOT replace the form with the Post (show post). That is only partially possible and causes issues on Loops (View), there fore it did not make it to this Code snippet.
Download and add to your theme:
hidden link
Add to your Functions PHP:
wp_enqueue_script("jquery");
wp_enqueue_script( 'jquery-form-js', get_template_directory_uri() . '/js/jquery.form.js', array('jquery'), '3.51.0-2014.06.20', true );
In any SINGLE CRED form JS Editor:
jQuery(document).ready(function() {
jQuery('#cred_form_4988_1').ajaxForm(function() {
alert("Thank you for your comment!");
});
});
Replace #cred_form_4988_1 with the actual ID of the CRED Form you’ll see in your browser console asa in this:
<form enctype="multipart/form-data" id="cred_form_4988_1" class="cred-form cred-keep-original" action="/toolset/2015/07/08/ajax-edit/?cred-edit-form=4988&_tt=1436396327" method="post">
If you have MULTIPLE CRED FORMS (of same form), outputted in a Views Loop
Means, you got x posts, and therefore x CRED Forms of same type,the ID of CRED is continuously increased by one, so the a above jQuery breaks. You should use here:
jQuery(document).ready(function() {
jQuery("[id^=cred_form_1096]").ajaxForm(function() {
alert("Thank you for your comment!");
});
});
We use now ("[id^=PART_OF_ID]")
You can also seek for all elements which contain (*=) or end up with ($=) known part of ID/class/type.
(example, id^, id*, id$)
DOC Links:
hidden link
hidden link
Note that above approach is NOT working properly on a View with many Posts, it means, some additional tweaks are needed.
As mentioned, I can not assist this sort of Custom coding as it goes into adding new features to CRED, which is something the DEV takes care of, in it's individual Road Map.