I figured it out. Simply, in my request, under data, I added
"nonce" : "<?php echo wp_create_nonce( 'refresh_my_plugin' ); ?>"
then to verify
if (isset($_POST['refresh_my_plugin']))
if ( wp_verify_nonce( $_POST['nonce'], 'refresh_my_plugin' ) )
refresh_my_plugin();
With incorrect wp_verify_nonce, I instead get a 403, which is reflected on the button with the error handler.
Related Posts:
- How to get a unique nonce for each Ajax request?
- Nonces and Cache
- Is it safe to assume that a nonce may be validated more than once?
- Multiple ajax nonce requests
- Using Nonces for AJAX that only retrieves data
- How to verify nonce from Bulk/Quick Edit in save_post?
- 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
- AJAX requests broken due to HTTPS for wp-admin
- Nonces, AJAX, script variables & security in WordPress
- Why does WordPress Heartbeat login not refresh the nonces?
- wp-admin AJAX with Fetch API is done without user
- How do I check if AJAX nonces are implemented correctly?
- How to check an ajax nonce in PHP
- Can a wp_nonce created from domain 1 to be verified on domain 2?
- how to send Ajax request in wordpress backend
- Identical wp_rest nonce returned from rest_api
- WP Admin AJAX Security – using POST to include a relative URL
- wp_create_nonce() in REST API makes user->ID zero
- ajax nonce verification failing
- SSO autologin WordPress + Ajax
- Nonce fails on ajax save
- Unable to successfully verify nonce
- Cache plugins and ajax nonce verification
- Nonce doesn’t validate in nopriv call
- Why does check_ajax_referer give a 403 error on https websites?
- 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?
- Using nonce when loading posts with AJAX
- Should wordpress nonce be placed in html form or in javascript file
- wp_verify_nonce not working on the mobile device
- How do I mitigate replay attacks when talking about actions that shouldn’t happen twice?
- AJAX form not working, still reloads on submit
- Ajax Security regarding user priviliges and nonces
- How to use nonces for frontend AJAX voting if the page gets cached?
- WordPress wp_localize_script nonce and ajax URL
- How to stop a nonce from being cached in an inline script, or alternatives to regenerate it if expired?
- Ajax in a settings page (update_option is undefined)
- Nonces can be reused multiple times? Bug / Security issue?
- gettext does not translate when called in ajax
- Execute one AJAX request after another AJAX request finished
- Load tinyMCE / wp_editor() via AJAX [duplicate]
- Load page content with AJAX using Fancybox?
- Dynamically changing navigation links (next and previous) via AJAX
- AJAX action not triggering PHP function
- add_action and Ajax
- Enqueue script dinamically
- Most performant way of fetching remote API data?
- Admin-ajax responds with 0 due to empty $_REQUEST
- Help with AJAX front end comment moderation
- wp_ajax_nopriv_xxx is not firing on one site, works on all others. -1 for logged out users
- Ajax Modal Flickers When Opened Multiple Times
- Increased CPU load due to admin-ajax.php spam
- Ajax image upload with media_handle_upload and form.js
- Can’t get result from sql using ajax result
- Theme Customizer – Conditional Controls
- WordPress AJAX – how to return true or false in the callback function
- WordPress Ajax POST Error 403 admin-ajax.php
- Ajax post returning full html page as response
- Which allowed API hooks work to add wp_ajax action?
- Why ajax doesn’t work on certain wordpress hooks?
- Pass additional parameter with async upload
- Performance optimization of tree like structure
- WordPress search results with Ajax, get_post_type() not working
- Audio TAG Not using MediaElement When Page is loaded through ajax
- WordPress ajax call returns a zero though die()
- wp_update_post onclick button using ajax
- wp_ajax declaration confusing for Front end
- WP_query offset seems to be counting draft post – AJAX load more
- Can’t load search results with ajax
- wp_ajax is not calling the action
- Deny dashboard access breaks ajax requests
- Run javascript upon successfully set featured image
- update_option in WordPress AJAX
- ajax in admin menu
- Ajax Favorite from foreach (how to specify which result result is processed)
- change wordpress pagination url after doing the request
- WordPress responds to the ajax request with readyState 1, 2, 3 before responding with 4
- Filter images from media library by guid meta field
- Counting Posts with multiple taxonomy and terms condition using MySQL and AJAX
- 400 Bad Request getting on AJAX Call
- admin-ajax.php 403 errors – no caching, permissions are fine
- How to add Ajax to this Pagination i made?
- Adding user using admin ajax by a user with custom role
- How can I run two AJAX requests simultaneously in WordPress?
- Issue developing an AJAX form with WordPress
- Can Ajax Action [add_action(‘wp_ajax_{action_name}’, ‘{action_name}’] be hooked into wp hook
- Strange AJAX problem (SOMETIMES works in Chrome/FF, ALWAYS works in Midori)
- How to check for dependencies for a specific page and enqueue them
- Loads posts of different year via AJAX call
- Ajax object comes back empty
- WordPress & Ajax
- wordpress ajax always return 0
- Can’t have two simultaneous charts using Apex Charts
- WordPress REST API FormData: Form Not Submitted When No Files Attached