Skip Navigation

[Resolved] CRED form AJAX not working

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by randallH-3 6 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1084112

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!

#1084658

Private fields are active here. Please tell me where I can find the Form on your site to replicate the problem.

#1087519

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.

#1089196

Hi Christian,

Still the same, I need to refresh the page to see the result.

#1089486

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/

#1093300

Thank you.