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
- How to make Contact Form 7 work when injected via AJAX in WordPress?
- Cross-Origin Read Blocking (CORB)
- Cross-Origin Read Blocking (CORB)
- syntax error: unexpected token <
- Infinite Scrolling in Asp.Net MVC with jQuery / AJAX Issues
- My javascript is returning this error: $.ajax is not a function
- ajax jquery simple get request
- jQuery get textarea text
- jQuery AJAX cross domain
- Set timeout for ajax (jQuery)
- How to generate a simple popup using jQuery
- What does on() in JavaScript do?
- jQuery AJAX submit form
- jQuery Ajax File Upload
- How can I upload files asynchronously with jQuery?
- Adding images to a Bootstrap Carousel with AJAX
- AJAX response error: net::ERR_EMPTY_RESPONSE
- 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
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- jQuery Ajax POST example with PHP
- Refresh/reload the content in Div using jquery/ajax
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- 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
- Download a file by jQuery.Ajax
- jQuery’s .on() method combined with the submit event
- Ajax success function
- Is there a JavaScript API? How to access public and private data in JS?
- Enable Submit Comment Without Page Reload (Using Ajax)?
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- Ajax Load More Posts in Category Page
- How to HTML5 FormData Ajax
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- Ajax call does not activate callback function
- How to properly use wp.ajax.post?
- WordPress Ajax always returns a 404 error
- Custom PHP endpoint for a plugin’s AJAX call
- How to link WordPress heartbeat to ajax form
- Refused to execute script from ‘***’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled
- WordPress Ajax Login without page reload
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- AJAX Implementation
- Trying to get single posts to load on the front page via ajax
- Dynamically changing navigation links (next and previous) via AJAX
- Ajax not firing properly using Firefox, but works in Chrome
- How to securely add an Ajax button to a WP Admin page?
- Quick Edit: Selected Custom Taxonomy Not Refreshing After Save
- Vue.js + AJAX Shortcode
- How to Use JSON With AJAX?
- fetching via fetch/ajax gutenberg block data from third party
- 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
- How to create popup same as wordpress popup feature
- Click loads template via ajax
- Nonces, AJAX, script variables & security in WordPress
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- Display notification only once
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- How to localized one js file for different actions?
- wp_ajax unauthenticated and authenticated
- wp-admin AJAX with Fetch API is done without user
- WordPress ajax function parameter value not being passed
- How to speed up admin-ajax.php in wordpress
- Admin Ajax and HTML5 Formdata
- Call javascript function when category was added via ajax
- Populating content dynamically via AJAX and Advanced Custom Fields [closed]
- Help with AJAX front end comment moderation
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- AJAX Contact Form Issue
- Sending jsPDF documents to the server
- How to add WP API and JS featured image attachment
- jQuery Ajax passing empty parameters to my function?
- Ajax return code 400
- WordPress customizer refresh screen after save
- Woocommerce Ajax Add cart not working
- Loading posts via AJAX in a hidden div with updated URL?