From quick look at your code you seem to be omitting where you are submitting request to. By default it is just current page, which isn’t typically equipped to receive the request.
Since you are using wp_ajax_
hook you need to point request at admin-ajax.php
endpoint. On admin side the URL is provided in ajaxurl
JS variable, on front end side you would need to provide it to your code yourself.
Related Posts:
- WordPress ajax success response
- contact form ajax empty response error message
- Wp mail does not work when Ajaxed to
- wp_mail 200 response but no mail sent
- wp_mail doesn’t work when logged in?
- Add Server Side validation in Ajax mail form
- How to send automatic response after form submission without plugin
- Sending email through Ajax without page refresh hangs on admin_ajax.php
- How to send the checkbox value to email
- Sending email with wp_email and AJAX
- WordPress Ajax JSON success return no being recognized
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- Initialize TinyMCE editor / visual editor after AJAX insert
- Displaying PHP Errors from admin-ajax.php
- wp_set_auth_cookie() doesn’t work in Ajax call
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- SSL breaks customizer: page isn’t returned from ajax
- Is it safe to assume that a nonce may be validated more than once?
- Using Nonces for AJAX that only retrieves data
- How to implement AJAX post navigation into WordPress?
- wp_ajax_[service] returning 0
- Ajax function returns -1
- Quick Edit: Selected Custom Taxonomy Not Refreshing After Save
- Is it OK to use a system cron to trigger a function hooked into the AJAX API
- Filter WP user acf field by ajax
- wp_verify_nonce always returns false when logged in as admin
- fetching via fetch/ajax gutenberg block data from third party
- How to make ajax content indexable by search engines?
- Conditional action hooks
- AJAX requests broken due to HTTPS for wp-admin
- Is it safe to use $_POST directly in my plugin instead of using admin-ajax.php to receive data from ajax?
- How to make get_theme_mod work with AJAX in the customizer preview
- How to check an ajax nonce in PHP
- Fatal error: Call to undefined function get_post() with ajax
- how to send Ajax request in wordpress backend
- wp_create_nonce() in REST API makes user->ID zero
- Plugin: AJAX query external API to sync to tables
- splitting the URL using jQuery
- How do I get reusable blocks via frontend REST API?
- Is there builtin way to use protected AJAX endpoint?
- AJAX Load more on CPT returning random posts
- WordPress admin-ajax.php not available for subscribers/contributors
- WP Ajax never returning any data / calling action
- Should I check for privileges before hooking into `wp_ajax_$handle` or after?
- Refresh Markercluster after ajax call
- How to load content from many posts on a page, only if needed
- Mapping Backbone Models to serialized array in wp_options table
- WordPress Settings api data not sanitized if i use ajax
- Ajax login without redirect/reload
- Ajaxify Form That Submits To Same Page To Display Post Data [closed]
- Ajax call with javascript in post content (not enqueued)
- What’s the latest I can hook into wp_ajax_%?
- Nonce doesn’t validate in nopriv call
- How to use ajax to get multiple outputs?
- Sql formatting for post data within function
- Get returned URL from wp_remote_post if response code is 302
- Change URL without reload Ajax
- Admin-ajax.php 400 error in custom theme
- 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
- Hide Load more Ajax button if there is no more users to load or less than the number?
- Send checkbox status with Ajax / JSON and save it
- How to get setting from separate file?
- wp_ajax action is not run when ajax trigger
- wp_ajax handler with multiple class instances
- admin-ajax.php (aborted) error when using jQuery.get
- Load page HTML content through AJAX
- Sharing variables in both actions wp_footer and wp_ajax
- Display full WordPress post under search form using AJAX
- Ajax callback not work
- WordPress Select Option Load Custom Fields
- Search live Ajax
- jQuery.post returns 0
- Ajax login fails: script sets cookies, but is_user_logged_in() returns false
- Opening Modal popup on Ajax form submission
- Ajax sometimes work and sometimes just don’t work
- admin-ajax error 400
- wordpress admin ajax trash_comment
- Failed to load resource: the server responded with a status of 404 (Not Found) admin-ajax.php
- Javascript output now showing in custom widget
- Create a post with REST API and adding a category
- how to correctly use json_encode with ajax
- delete post meta data in array WordPress
- How to trigger lost password email using REST API?
- Display post thumbnail after clicking on post id with AJAX
- How to block search engines indexing certain AJAX actions
- wp_ajax_action, wp_ajax_nopriv_action not working
- Manually cache a special, non-WP-but-using-WP page (e.g. Ajax results) with W3TC
- Is it a good idea to init ajax functions only while ‘DOING_AJAX’
- register_setting and AJAX?
- Static var overwritten with WP AJAX action, works fine without AJAX
- ajax response is 0 instead of ‘script’ [duplicate]
- using ajax to query sql
- A refreshless WordPress website
- Add “load more” functionality to an AJAX response
- weird Internal Server Error – no error log produced
- Why are the most recent posts not appearing in a fetch request, unless I’m logged in?
- Successful ajax call returns lots of whitespace and text of code with 0
- How to submit a button automatically after every scheduled hours?
- At what stage does wp_ajax hooks gets applied during WordPress request?