Home › Forums › Front-end Issues › Ajax font-end save stopped working? › Reply To: Ajax font-end save stopped working?
Hey John, I was able to solve this by moving the ajax save completely into my own function. Here is the function in case anyone finds this later:
$('.acf-form').on('submit', function(e){
e.preventDefault();
// define the form data
let $form = $(e.target);
// submit the form
$.ajax({
url: window.location.href,
method: 'post',
data: $form.serialize(),
success: function(data) {
$("a.save").removeClass("saveActive");
$("a.save").addClass("saveComplete");
$("a.save i").removeClass('fa-spinner');
$("a.save i").addClass('fa-thumbs-up');
$("#saveText").html("Saved");
setTimeout(function(){
$("a.save").removeClass("saveComplete");
$("a.save i").removeClass('fa-thumbs-up');
$("a.save i").addClass('fa-save');
$("#saveText").html("Save");
}, 3000);
}
});
console.log("form submit 1");
});
I don’t know why it stopped working. Something about the e.preventDefault() stopping this:
acf.add_action('submit', function($form){
// old ajax code was in here
});
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 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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.