Forum Replies Created

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter eripanci

    (@eripanci)

    Hi there,

    I enabled the reCAPTCHA V3 and it fixed the problem firstly but on the second try and subsequently, it does show this error -> Something went wrong, please try after some time and on the console, it’s a 403 error from wp-admin/admin-ajax.php.

    I enabled the WordPress REST API, but didn’t make any difference.

    I noticed another thing (without enabling the 2 things above): When I input a normal e-mail, it shows that e-mail 3 times on the list, and also it sends 3 emails. But when I put a test email (like [email protected]), it does only show it once.

    – Could you find any js error from your side?

    Nope. On the normal env without enabling v3 reCaptcha, there’s no error on the console.

    – Check whether any cache plugin is active

    For the cache, we use the WP Rocket plugin.

    We also require your product url

    Sorry, what do you mean by product URL? This happens on all the products on the site.

    Thanks!

    Thread Starter eripanci

    (@eripanci)

    Any answers for this?

    The problem continues to persist.

    Thread Starter eripanci

    (@eripanci)

    Most of SPA libraries (if not all) use the History API to modify the URL on the browser. I thought to find an event in which is triggered every time the URL is changed by using history.pushState function. A similar property is WindowEventHandlers.onpopstate, but this event is not triggered when using pushState, but only functions like history.back(), history.go(2). Anyway, I managed to find a function modified to also work with pushState:

    (function(history){
    	var pushState = history.pushState;
    	history.pushState = function(state) {
    			if (typeof history.onpushstate == "function") {
    					history.onpushstate({state: state});
    			}
    			
    			return pushState.apply(history, arguments);
    	};
    })(window.history);

    Now if we add this below:

    window.onpopstate = history.onpushstate = function() { … }

    an event is triggered every time the URL is changed using pushState function.

    I added a new variable “var is_spa_site = false;” and if this event is triggered, I change the variable to true. This is triggered before your click event so when the code goes to your callBack, I make a check of is_spa_site variable, if it’s true, there’s no need to go into your callBack code.

    All the code can be found here: https://gist.github.com/erip2/5ebbfd0ae0f9cafd08af09fee2b46635

    P.S. I tried to add a <em>window.onpopstate = null</em> after the callback function in order not to trigger this event anymore since we know that this is a SPA with only one use of pushState, but I noticed that the JS file was being initialized again even on the new page, so it didn’t make any difference.

Viewing 3 replies - 16 through 18 (of 18 total)