You can’t send the data to admin-ajax.php as JSON:
data: JSON.stringify({
action: "process_coupon"
}),
For the wp_ajax_ actions to be fired, WordPress checks $_REQUEST['action'], but this is not populated by PHP when the form is submitted as JSON. The correct way to send the request with jQuery is to pass the data like this:
data: {
action: "process_coupon"
},
Related Posts:
- Drag and drop multiple file upload using Ajax WordPress
- Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)
- WordPress AJAX Call Not Return Result
- Ajax Modal Flickers When Opened Multiple Times
- splitting the URL using jQuery
- Refresh Markercluster after ajax call
- wp_mail doesn’t work when logged in?
- How to display contact form 7 form in vanilla js without jquery in frontend
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- javascript onClick update user_meta from jquery.ajax
- Ajax sometimes work and sometimes just don’t work
- React to AJAX adding to the page
- Download doccument on server rather than clients browser
- Javascript output now showing in custom widget
- WordPress Ajax send response on every iteration of a loop
- AJAX call not initializing for non-admins in WordPress
- JQuery UI Autocomplete/Autosuggest WordPress
- How to show custom fields in modal in category page
- Cross-Origin Read Blocking (CORB)
- ajax jquery simple get request
- Set timeout for ajax (jQuery)
- jQuery AJAX submit form
- jQuery Ajax File Upload
- How can I upload files asynchronously with jQuery?
- Access Control Request Headers, is added to header in AJAX request with jQuery
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- JavaScript implementation of Gzip
- How to manage a redirect request after a jQuery Ajax call
- jQuery: Performing synchronous AJAX requests
- FormData append not working
- Uncaught TypeError: Cannot read property ‘toLowerCase’ of undefined
- How to HTML5 FormData Ajax
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- How to properly use wp.ajax.post?
- WordPress Ajax Login without page reload
- How to securely add an Ajax button to a WP Admin page?
- Vue.js + AJAX Shortcode
- How to Use JSON With AJAX?
- Using wp_ajax and wp_ajax_nopriv hooks
- ajax and nonce when JavaScript is in a seperate file
- AJAX issue – Uncaught SyntaxError when processing Zip File
- Display notification only once
- wp-admin AJAX with Fetch API is done without user
- Call javascript function when category was added via ajax
- Populating content dynamically via AJAX and Advanced Custom Fields [closed]
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- How to add WP API and JS featured image attachment
- Ajax return code 400
- class click counter save number
- WordPress Admin AJAX Serialize
- Show Post Content with AJAX
- How to handle 400 status in Ajax [duplicate]
- WooCommerce Ajax Cart Update Stopped Working
- How to search using ajax for exact phrase or words in an input field?
- AJAX not Working with php as supposed
- How do I Import / Upload Files with jQuery AJAX?
- All AJAX requests return a 400 error
- WordPress Heartbeat API cannot parse data
- wordpress add_action() issue in ajax call
- Ajax Validation for reCaptcha
- javascript ajax and nonce
- Making POST request with AJAX returns a 400 error (without jQuery)
- Call current post URL in ajax
- AJAX Success Function using JS substr() fails in WP 4.1 vs 4.0
- admin-ajax.php (aborted) error when using jQuery.get
- Ajax page load without reload
- Load page HTML content through AJAX
- Using jQuery .after inside loop
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Ajax page load in wordpress the right way?
- Display full WordPress post under search form using AJAX
- WordPress Select Option Load Custom Fields
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- Jquery POST Ajax Return null data in wordpress
- Search live Ajax
- WordPress POST AJAX call, var_dump($_POST) NULL and AJAX response empty when inside ob_start
- jQuery.post returns 0
- Admin-ajax.php 404 error
- How to pass values from one function to the other using an array variable
- Ajax Call not Working in Plugin
- Opening Modal popup on Ajax form submission
- jQuery ajax method does not return data
- WordPress live search and filter
- Update $wpdb query with AJAX
- AJAX to add to cart multiple products woocommerce
- AJAX POST Value not being returned – WordPress – AutoTrader API
- How can i get the same ajax result using WP REST API instead of admin-ajax?
- Ajax call on class returns old data
- Create a post with REST API and adding a category
- Get post details with pure javascript ajax
- Filterable posts using categories
- How to submit form data in the same page in WordPress without reloading the page?
- Automatic add space if user enters number(any digit)
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- 500 (Internal Server Error) of external php file
- Can’t access data from database using AJAX
- notify users when changed database
- Running js in html code with same content
- How to get current_user_id from wordpress in node js?
- How to update my jquery/PHP function to add/remove user as favorites in (WordPress) users list