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
- Cross-Origin Read Blocking (CORB)
- jQuery get textarea text
- What does on() in JavaScript do?
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- jQuery Ajax POST example with PHP
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- 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
- WordPress Ajax always returns a 404 error
- 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
- Quick Edit: Selected Custom Taxonomy Not Refreshing After Save
- fetching via fetch/ajax gutenberg block data from third party
- Click loads template via ajax
- How to speed up admin-ajax.php in wordpress
- Help with AJAX front end comment moderation
- Sending jsPDF documents to the server
- jQuery Ajax passing empty parameters to my function?
- Loading posts via AJAX in a hidden div with updated URL?
- AJAX request status 200 but no actual “response”
- Correct way to write jQuery functions in WordPress
- AJAX Load more on CPT returning random posts
- Scripts not appending to element in AJAX call – why?
- Save Search System
- dynamic dependent select dropdown
- AJAX request randomly stop working and returns error 400
- Making an ajax request from a different domain
- Performance optimization of tree like structure
- Radio buttons live refresh in the customizer
- Trouble with WordPress Ajax Login System – 302
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Fancybox type popup window that’s not an iframe
- Why is wp_localize_script returning false?
- How to pass parameters from jQuery ajax into PHP function?
- url – ajax loaded but no JS
- WordPress Heartbeat API cannot parse data
- merge wp rest api query to get posts per category does not work
- wordpress add_action() issue in ajax call
- Using admin-ajax prevents regular php form submission
- Properly embed javascript into WP (using function.php) – doesn’t work?
- WP AJAX post filter > do something with empty value
- Load more posts in the same category – Ajax + Timber
- Loading two different AJAX requests on two different pages
- How to jQuery Ajax show new data from successful insert?
- Hide Load more Ajax button if there is no more users to load or less than the number?
- Why i can’t get custom fields value or post ID via Ajax?
- Call current post URL in ajax
- Custom AJAX form not working async
- Accessing an API with jQuery and AJAX
- admin-ajax.php (aborted) error when using jQuery.get
- Replace link with form to pass variables to javascript / ajax
- Load page HTML content through AJAX
- Get localize of a loaded javascript
- Display full WordPress post under search form using AJAX
- WordPress Select Option Load Custom Fields
- Fetch value using AJAX in WordPress
- Query data after an Ajax insert
- AJAX not working when clicking load more button, when two terms are present in tax_query
- Search live Ajax
- jQuery.post returns 0
- Admin-ajax.php 404 error
- How to pass value from ajax to php in no conflict mode?
- Opening Modal popup on Ajax form submission
- JS working when used normally but not in wordpress
- JS global variable doesn’t update
- How to echo a PHP code into WooCommerce variation product?
- How to call a function from functions.php with ajax?
- Ajax show custom post data form & script
- Create a post with REST API and adding a category
- Ajax post doesnt call succes after got the response
- Get ajaxForm response value
- How to submit form data in the same page in WordPress without reloading the page?
- Jquery wrap permalink in a data-attribute?
- Colorbox not working on native WordPress gallery when gallery is loaded thru AJAX
- Find the method which AJAX GET calls
- ‘Dehighlighting’ navigation once clicked
- WordPress sound bell when new data will add
- AJAX admin Internal 500 error Failed to Upload
- Escaping admin_url output being passed to js (esc_js vs esc_url)
- How to submit a button automatically after every scheduled hours?