I created a form with an AJAX, but it is not saving.
Please add private fields so I can share the URL with you.
Thanks!
Private fields are active here. Please tell me where I can find the Form on your site to replicate the problem.
I think the problem is this Form does not contain any post fields, only generic fields. Try adding a hidden post title field inside the credform shortcodes like this:
<div style="display:none;">[cred_field field='post_title' value='' urlparam='' class='form-control' output='bootstrap']</div>
Let me know if this does not resolve the problem and I'll take a closer look.
Hi Christian,
Still the same, I need to refresh the page to see the result.
I'd like to clarify that needing to refresh the page to see the result and the Form not saving are two different things. The Form is actually saving successfully, but the button label is not updated to reflect the new state. When the page reloads, the correct button label is displayed. I did some more investigation and it looks like custom JavaScript code is responsible for changing the button text to "Save" or "Unsave" when the page loads. From your Form's JS editor panel:
jQuery(window).bind("load", function() {
jQuery( "form[id^='cred_form_6682']").find("input[type='submit']").val(jQuery( "input[name='remove-save-2']").length ? "Unsave" : "Save");
});
After the Form is submitted, that button label remains as it was before the Form was submitted. Unfortunately there is no JavaScript API for Forms, so there is no public event or hook for triggering JavaScript after an AJAX Form is submitted successfully. You may be able to use custom JavaScript to tap into global jQuery AJAX events, but I'm not able to offer that kind of assistance here in the forums. Otherwise disabling AJAX submission is required to trigger UI changes based on a Form's submission.
https://api.jquery.com/category/ajax/global-ajax-event-handlers/