Your add_action()
calls for the AJAX handlers are too late.
Add these hooks earlier, the best action is probably wp_loaded
:
add_action( 'wp_loaded', 'register_ajax_handlers' );
function register_ajax_handlers()
{
add_action( 'wp_ajax_jp_ajax_request', 'jp_ajax_process');
add_action( 'wp_ajax_nopriv_jp_ajax_request', 'jp_ajax_process');
}
See also: Debug AJAX.
This code should be placed in a plugin or in your theme’s functions.php
.
Related Posts:
- How to link WordPress heartbeat to ajax form
- jQuery’s .on() method combined with the submit event
- WordPress AJAX File Upload – FrontEnd
- Nonces and Cache
- How to HTML5 FormData Ajax
- admin-ajax.php doesn’t work when using POST data and Axios
- Contact Form 7 Custom Post Action
- Custom Form with Ajax
- ajax – why multiple calls to wp_create_nonce() return same value?
- Update user meta using with ajax
- WordPress AJAX Login Screen
- Ajax form submission from admin panel
- How to correctly load wordpress in a non WP script for AJAX request
- Confused on AJAX submit form through page template
- how to use reCaptcha v3 in wordpress custom login form?
- Prevent page reload after ajax form submission
- Insert wp_editor on front-end with AJAX?
- submitting form via admin-ajax.php returns 0
- Admin Ajax and HTML5 Formdata
- Help with AJAX front end comment moderation
- jQuery Ajax passing empty parameters to my function?
- Using ajax with wordpress
- Three level taxonomy dropdown frontend
- Ajax image upload with media_handle_upload and form.js
- Ajax post returning full html page as response
- Sending variable from ajax on form submit
- Performance optimization of tree like structure
- contact form ajax empty response error message
- Can’t trigger an AJAX function with a submit button in the dashboard
- Dynamically add more fields/remove last field in a form
- Ajaxify Form That Submits To Same Page To Display Post Data [closed]
- Is it secure to use admin-ajax.php in front?
- Best way to use ajax front-end?
- Using admin-ajax prevents regular php form submission
- Specify ABSPATH in jQuery url
- ajax form is returning the dreaded “[HTTP/1.1 400 Bad Request” and a zero
- wp_ajax declaration confusing for Front end
- Output multi-steps form results in same page
- How to get post from pure frontend AJAX (using only post ID)?
- Using get_theme_mod in php ajax form doesn’t work
- How to create a form button that executes a function?
- How to stop being directed to admin.php after sending request to admin-ajax.php
- How to display contact form 7 form in vanilla js without jquery in frontend
- Should wordpress nonce be placed in html form or in javascript file
- Add Server Side validation in Ajax mail form
- How to send automatic response after form submission without plugin
- How to prevent my external API call from being called by anyone but me (my site)
- Opening Modal popup on Ajax form submission
- Registration form AJAX check for existing username (simple version)
- Issue developing an AJAX form with WordPress
- Ajax show custom post data form & script
- Update user meta via ajax from frontend, saving issue
- Edit user meta on front-end via AJAX
- Using AJAX on Contact-form the WordPress way
- Error while submitting form using AJAX and php
- How to test if in dashboard, bypassing Ajax quirk
- Ajax contact form returnig 0
- Ajax Form data is not posted back to the get_results()
- Using AJAX for dynamic settings pages
- Ajax Form seems to post, but does not return
- ajax page template
- Bad Request when adding new post via ajax form
- gettext does not translate when called in ajax
- Front End Post Save Child terms
- Load tinyMCE / wp_editor() via AJAX [duplicate]
- Plupload in metabox – AJAX action not working in Class
- CPU usage: AJAX and Heartbeat API on admin pages
- Can part of my WordPress website be headless?
- Nonces, AJAX, script variables & security in WordPress
- Extending wp JavaScript base class to make a post request to a custom REST endpoint
- 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
- 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
- Pass additional parameter with async upload
- WordPress search results with Ajax, get_post_type() not working
- Create post using Ajax
- Ajax calls from the theme directory
- How to pass parameters from jQuery ajax into PHP function?
- use jQuery.load() to include a php file in a div, wp_query() is part of php file
- Redirect after saving form; and yet use wp_die()
- How to request admin-ajax.php correctly when wordpress URL and site URL are different?
- Load more posts (Ajax) in tabbed sidebar on single.php
- Something strange with ajax
- admin-ajax.php returns 0 even when the post status code is 200 OK
- REST public POST giving 403 forbidden nginx
- Content including hooks inside wp-settings.php are being called twice in WordPress
- JS global variable doesn’t update
- 404 error custom post type rest api
- WP Ajax returning 0, can’t find action
- Jquery wrap permalink in a data-attribute?
- Load .php file into div using ajax
- Native WordPress Video Shortcode Not Working After Post is Loaded via Ajax
- AJAX admin Internal 500 error Failed to Upload
- Class property not visible inside ajax callback function?
- Adding custom fields to Wired Impact Volunteer Management Plugin
- randomly get 400 error while user is logged in wp_ajax