Skip Navigation

[Resuelto] Async form submittion?

This support ticket is created hace 6 años, 11 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 5 respuestas, tiene 2 mensajes.

Última actualización por Christian Cox hace 6 años, 10 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#603474

Hi,

Very often, when working with Toolset, I end up adding a lot of custom logic to the forms (via cred_submit_complete) which eventually slows down the submission itself and worsens the user experience. So I have two questions regarding that:

1. In some cases users tend not to pay attention to the browser signs that show that the page is already reloading and click the submission button a few times, thinking that one was not enough. This results in the same data being submitted twice or even 3 times.

Is there a way to aviod it? Maybe by adding some JS loader and deactivating the submit button after the first submission? Can you suggest a solution?

2. I know there is a way to execute the submission logic asynchronously and make it fast for the user while the changes in the database are being made on the background. But I have no idea how to do that and especially with CRED. Can you suggest something?

Thank you very much in advance.

Happy New Year!

#603565

This results in the same data being submitted twice or even 3 times.
CRED can disable the submit button during AJAX submission to prevent this, so I suspect something else is going on.
- What version of CRED are you using? If you are not using the latest version, please update and test again.
- If you temporarily activate Twenty Seventeen, does the Submit button become disabled during AJAX submission?
- What are your settings in Toolset > Settings > Forms > Styling?
- What is your setting in Toolset > Settings > General > Bootstrap loading?
- What theme are you using, and does it include or load Bootstrap? If so, what version?

2. I know there is a way to execute the submission logic asynchronously and make it fast for the user while the changes in the database are being made on the background. But I have no idea how to do that and especially with CRED. Can you suggest something?
I'm not sure what you mean here. WordPress doesn't enqueue data to be inserted later when you create a post, it inserts the data right then on demand. Same with CRED - it inserts data in the database synchronously during form submission, even if you choose AJAX submission. What you're describing sounds like processes running in the background after the form submission. The only background processes I'm aware of are wp_cron and basic cron jobs on your server. Internally, CRED uses wp_cron to schedule notifications, but does not provide any additional functionality that would delay post submission or manipulation for a later time.

To speed the process up, I guess you could only insert the minimum post data you need with no custom manipulation or processing in CRED hooks. Then you could set up a function that performs more advanced calculations and data manipulation later using wp_cron (https://codex.wordpress.org/Function_Reference/wp_cron). That setup is beyond the scope of the support we provide here in the forums, unfortunately. I can help you access any Toolset data you need to perform the manipulation, but setting it up to run periodically would be your responsibility.

Also you would need to consider that posts would not appear for a period of time while waiting for the cron to run, or may appear with inaccurate or incomplete data while your manipulations are pending. All in all, I think you'll have better luck optimizing the form submission process rather than trying to schedule posts for insertion at a later time. That could involve database query optimization, getting a dedicated server vs a shared server, increasing your allocated PHP memory, upgrading to PHP 7+, and so on. A plugin like Query Monitor can help you identify bottlenecks in your code. If any Toolset queries take longer than 0.5ms, we can try to investigate those in more detail. If you'd like to do that, please open a separate ticket so we can investigate that independently of the submit button issue. Thanks!

#603963

Hello Christian,

Thank you very much for such a comprehensive answer.

As for the ajax, I am not using the ajax submission for that specific project because it is not working as I need it to. Here is what's happening:

The form is placed into every post in a view. The first submission goes without a problem, but when I click submit button on the second post (after the first one reloaded the page), it does not reload the page anymore, only says "Please Wait. You are being redirected...".

The truth of the matter, I'm not quite sure why the ajax option is offered at all, as it reloads the page anyway. I use it in none of my projects. In many cases this "Please Wait. You are being redirected..." pops up without any formatting and just makes the design of the site look bad.

I'll keep the ticket open in case you want to look into the problem I described.

As for using cron to schedule some of the logic for later, for that specific project it's a good idea, thank you. I didn't think about it myself.

Have a nice day.

#604092

when I click submit button on the second post (after the first one reloaded the page), it does not reload the page anymore, only says "Please Wait. You are being redirected...".
Okay that's unusual. Please answer these questions so I can help diagnose the issue.
- What version of CRED are you using? If you are not using the latest version, please update and test again.
- If you temporarily activate Twenty Seventeen, does the Submit button work as expected in the 2nd submission?
- What are your settings in Toolset > Settings > Forms > Styling?
- What is your setting in Toolset > Settings > General > Bootstrap loading?
- What theme are you using, and does it include or load Bootstrap? If so, what version?
- Are any JavaScript errors displayed in the console during the 1st or 2nd submission?

#605090

Hi Christian,

- What version of CRED are you using? If you are not using the latest version, please update and test again.

It's the last one.

- If you temporarily activate Twenty Seventeen, does the Submit button work as expected in the 2nd submission?

I'm going to need a bit of time to set this test, as the code that displays the page is a part of the theme.

- What are your settings in Toolset > Settings > Forms > Styling?

Load CRED legacy style sheets on front-end

- What is your setting in Toolset > Settings > General > Bootstrap loading?

The theme or another plugin is already loading Bootstrap 3.0

- What theme are you using, and does it include or load Bootstrap? If so, what version?

Custom built, based on enlace oculto

- Are any JavaScript errors displayed in the console during the 1st or 2nd submission?

None.

I'll come back to you with the results of the test with Twenty Seventeen. Thanks.

#605491

Sure, I'll mark this ticket as pending an update from you. No need to reply right now. The ticket will remain active for 30 days.