that looks good in my eyes. but i just had the same issue, that’s why i stumbled over your question.
i fixed it in my case with
if (!wp_verify_nonce($_POST['nonce'], 'nonce')) {
die(__('Security Check failed', 'textdomain'));
}
at the very beginning of my ajax action. no idea, where the 403 issue came from, since it worked on desktop machines, but not on my mobile. weird.. give it a shot and let me know, if this helps.
one other thing i saw in your code, but not sure, if it is causing issues: one time you use single quotes, the other time doubles. try to be consistent here.
Related Posts:
- Nonces and Cache
- Is it safe to assume that a nonce may be validated more than once?
- Multiple ajax nonce requests
- AJAX requests broken due to HTTPS for wp-admin
- Nonces, AJAX, script variables & security in WordPress
- How do I check if AJAX nonces are implemented correctly?
- WP Admin AJAX Security – using POST to include a relative URL
- ajax nonce verification failing
- Using nonce when loading posts with AJAX
- Should wordpress nonce be placed in html form or in javascript file
- Ajax Security regarding user priviliges and nonces
- How to get a unique nonce for each Ajax request?
- WordPress Ajax Data Security
- Nonces can be reused multiple times? Bug / Security issue?
- SSL breaks customizer: page isn’t returned from ajax
- Using Nonces for AJAX that only retrieves data
- How to verify nonce from Bulk/Quick Edit in save_post?
- How to add WordPress nonces to ajax request
- Security – Ajax and Nonce use [closed]
- Nonces and Ajax request to REST API and verification
- Ajax function returns -1
- Serving nonces through AJAX is not refreshing nonce, returning 403 error
- wp_verify_nonce always returns false when logged in as admin
- ajax and nonce when JavaScript is in a seperate file
- wp_verify_nonce doesn’t return true on server when it matches the nonce
- Why does WordPress Heartbeat login not refresh the nonces?
- wp-admin AJAX with Fetch API is done without user
- How to check an ajax nonce in PHP
- Can a wp_nonce created from domain 1 to be verified on domain 2?
- Is it safe to manually sign a user in using AJAX?
- how to send Ajax request in wordpress backend
- Identical wp_rest nonce returned from rest_api
- wp_create_nonce() in REST API makes user->ID zero
- SSO autologin WordPress + Ajax
- Should I check for privileges before hooking into `wp_ajax_$handle` or after?
- How can I set cookies on both secure and non-secure origins at the same time?
- Nonce fails on ajax save
- Images loading over http instead of https
- Is it secure to use admin-ajax.php in front?
- Unable to successfully verify nonce
- Cache plugins and ajax nonce verification
- Nonce doesn’t validate in nopriv call
- WordPress is creating nonce as a logged in user but verifying it incorrectly
- javascript ajax and nonce
- How to check nonce lifetime value of plugins?
- 200 return code on ‘POST /wp-admin/admin-ajax.php’ while NOT logged in
- Custom RPC end-point security best pratice?
- How to prevent my external API call from being called by anyone but me (my site)
- wp_verify_nonce not working on the mobile device
- How do I mitigate replay attacks when talking about actions that shouldn’t happen twice?
- check_ajax_reffer not working when logged
- How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?
- AJAX form not working, still reloads on submit
- How to force the admin-ajax.php file to load over HTTPS?
- How to use nonces for frontend AJAX voting if the page gets cached?
- Can I make an ajax response cross-domain?
- WordPress wp_localize_script nonce and ajax URL
- Using Backbone with the WordPress AJAX API
- Why is a 500 error generated by admin-ajax.php not going into the Apache error log?
- Verify nonce in REST API?
- How do I hook an Ajax request into a PHP callback?
- Gutenberg – how to correctly perform ajax request on backend
- get_template_part execute with ajax
- How declare Ajax functions ussing SHORTINIT
- Load custom formatted comment with AJAX: reply link isn’t rendered?
- Is there a way to optimize function that is used for returning data in an ajax-call?
- WP REST API route request explain
- Check if username exist with AJAX
- How to localized one js file for different actions?
- WooCommerce: Translation lost on AJAX call in Checkout page [closed]
- Async Loading of Custom Posts
- How to add WP API and JS featured image attachment
- Using AJAX with Forms
- Get Author Post on author.php with AJAX
- Can’t publish post using ajax
- Customizer AJAX using buttons
- Can’t trigger an AJAX function with a submit button in the dashboard
- AJAX Call is Only Returning 100 Results from Query
- AJAX and -1 response
- How to make custom button link on the WordPress Admin Bar run by AJAX
- Ways to load admin-ajax faster without initializing all plugins?
- is_single() conditional check inside ajax php function
- Why do Metabox use Nonces?
- Ajax call in WordPress – unable to display the data on the page
- How to reuse get_template_part() containing a simple loop to work with AJAX correctly?
- Need help with ajax
- Tabbed feeds with ajax vs. without on homepage [closed]
- javascript onClick update user_meta from jquery.ajax
- How to ignore WP_ERROR caused by “get_the_excerpt” method in an AJAX call?
- Not getting ajax success response on insert/update row to database
- https rewrite not working for All in one security Brute force > rename login url
- enqueue style using admin-ajax.php
- Can’t get next post info with ajax
- How to inject data content from external json into a modal, using UIkit?
- How to paginate Ajax result
- Cannot access class properties from ajax call in wpordrpess
- why is my main.js not loading?
- Enqueue dynamically generated javascript
- First time doing Ajax with WP, how to do it?
- Run PHPMailer function after ajax function completes that adds row to custom table