#StackBounty: #javascript #jquery #ajax #recaptcha How to verify recaptcha in server call?

Bounty: 50


I used to check my recaptcha with a simple form submit with POST to “/login”.

I need to change my implementation for security reasons and would like to do something like:

1) Jquery form submit.

2) Make call to server to call verify recaptcha on the server.

3) Receive response without reloading page.

4) Accept login request or not based on response.


It looks like I could make an AJAX request ? But I don’t know how.



<button class="btn btn-default" id="loginButton">Submit</button> <span class="userLinks"> <a class="logLinks" href="/users/register">Register</a><a href="/users/password">Password?</a></span> </form> </div> </div> <% include ../partials/indexScripts %> <script> $("#loginForm").submit(function(e) { e.preventDefault(); var email = $("#loginEmail").val(); var password = $("#loginPassword").val(); // WOULD LIKE TO MAKE SERVER CALL HERE TO CHECK RECAPTCHA BUT I DONT KNOW HOW $this = $(this); $.ajax({ type: "POST", url: "users/register", data: $this.serialize() }).done(function(data) { if (successfulRecaptcha) { firebase.auth().signInWithEmailAndPassword(email, password ).then( authData => { } else { console.log("You are a robot!"); }


router.post('/login', function(req, res, next) {
    verifyRecaptcha(req.body["g-recaptcha-response"], function(success) {
        if (success) {

        } else {


Get this bounty!!!