Home › Forums › General Issues › Frontend form – post via ajax? › Reply To: Frontend form – post via ajax?
Hi @hwk , I testet your code and it works great! The only thing now still missing is a way to hook into the validation ajax request, so that I could include image upload capabilities, as described by @valpe . Do you know how to do that? You seem like a pro π
…in the meantime, I used this code (still two ajax requests, but much cleaner than my original solution):
acf.add_filter('validation_complete', ( json, $form ) => {
// if errors?
if( json.errors ) {
return json;
}
var formdata = new FormData($form[0]);
$.ajax({
url: window.location.href,
method: 'post',
data: formdata,
cache: false,
processData: false,
contentType: false,
success: (data) => {
acf.validation.toggle($form, 'unlock');
//... show success message ...
}
});
return json;
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
π Weβre excited to announce we've released Composer support for installing ACF PRO.
— Advanced Custom Fields (@wp_acf) January 31, 2023
π #ComposerPHP fans rejoice!
β¨ Please see the release post for all the details and full instructions. https://t.co/ebEfp61nlR
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.