Skip to content
Advertisement

Send Image file with Google reCaptcha v2 token to PHP via jQuery + Ajax

I want to POST and upload image via AJAX with Google reCaptcha v2 validation. but I am facing an issue that I am not not able to send image with caption text with google recaptcha token in Ajax. I coded two function as I know but both was not working. The function I made is the code snippet.

Please help me how I send Image with text in Ajax with reCaptcha token in PHP / jQuery/ AJAX.

JavaScript
JavaScript

Advertisement

Answer

Change your HTML and formData to the following

Give an id selector your caption banner.

JavaScript

Store using the formData like this and then sent formData via ajax

JavaScript

You can also use jQuery .serialize method to send data to your backend via ajax

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement