xpertbot / craft-wheelform

Craft CMS 4 Form with Database integration
MIT License
66 stars 32 forks source link

Update README.md ajax recaptcha #302

Closed masiorama closed 8 months ago

masiorama commented 10 months ago

Add wheelformProcessRecaptchaCallback() usage info if implementing recaptcha with ajax

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

masiorama commented 8 months ago

@xpertbot fyi

xpertbot commented 8 months ago

Hello,

Sorry, I've been a bit busy lately. Let's change the example a bit; if we leave the examples too vague and without context, they tend to cause confusion to users who just copy-paste. Let's do something like:

""" If implementing Recaptcha with Ajax, keep in mind that it is necessary after each Ajax request to refresh the recaptcha token to avoid an invalid recaptcha validation error (see issue 242).

// Example using Fetch API
const myRequest = new Request('endpoint.json', {
    method: 'POST', // any allowed Method
    param: value
});
fetch(myRequest)
.then((response) => response.json())
.then((data) => {
    // Use respose `data` here

    // Refresh Recaptcha token 
    wheelformProcessRecaptchaCallback()
});

Also, Please submit the Pull Request to the dev branch so we can later merge it into the master release. Thank you,

masiorama commented 8 months ago

Like this? https://github.com/xpertbot/craft-wheelform/pull/307