It’s better to use the wp_ajax_ action in an init action.
In fact, wp_ajax_ action need to be accessable from anywhere. Use of the init action hook could make it work like it does.
Hope it works
Related Posts:
- Select dropdown not showing selected value php
- Filter Select results based on selection
- Display parent and child taxonomies in separate drop down select fields
- wp_dropdown_pages auto submit
- HTML dropdown setting not showing last saved value in the database
- Sorting dynamic select/dropdown for Contact Form 7 of Modern Tribe Events posts
- Custom Taxonomy Select Menu: Setting default option value?
- How to set value selected using select2 jquery plugin
- How to make a pagination with dropdown selection?
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- Open WordPress Page from selected option dropdown
- WordPress AJAX Pagination with query_posts
- Do I require the use of nonce?
- Drop down+sort blog posts date added/most popular
- Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
- PHP calling AJAX function that relies on passed PHP function values not working
- Looking for a better way to handle an ajax script that pulls in post data on click
- How to add default images into theme customizer image control?
- Can’t use get_results() in ajax query
- Debugging PHP object during Ajax call in WordPress
- WordPress Ajax Data problem
- Problem with WordPress Ajax form
- 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]
- Passing jQuery value using Ajax to a page template
- How to set a custom path, for ajax image upload folder in admin?
- ajax_object is not defined when ajax calls the function
- Page Reloads Before AJAX Request Finishes
- Why is this Ajax not working?
- Ajax return code 400
- how to save selection meta data in user profile on frontend
- Create onClick Event to Re-load a Widget
- Creating a Multi-Level Associative Object Using AJAX
- How to store data from multiple forms using ajax and php
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- Gutenberg block – Save PHP function’s output as HTML?
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- Ajax date_query not working past the first iteration
- Posting and image insertion problems after EasyApache4 and PHP 7 upgrade
- [jQuery]Adding shortcode
- how to update and display an option without reloading the page
- WordPress admin-ajax.php 400 bad request
- Problem with AJAX in wordpress plugin
- How to keep track of when a vote is cast?
- set post limit at load more ajax wordpress
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Ajax filter button display all posts
- Compare $_POST returned values with term array
- How to use AJAX to call php page with parameter
- admin-ajax GET response bad request
- javascript variable to wordpress php variable
- Output votes to div dynamically in wordpress
- Incrementing PHP variable onclick to display posts by month
- Proper way to use WordPress function with AJAX PHP file
- How to use AJAX in WordPress in MYSQL query?
- Save the value of a wp_dropdown_pages
- Live search from database table
- Processing ajax call to php to insert into mysql database
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- Display WordPress search results based on the selected Sub-Category
- Deleting records with AJAX, deleting records as I search
- Using some Loop or repeatable fucntion in AJAX and PHP to reduce repeatability
- Database SQL query error
- How do I call a value from the datase using ajax
- Post form – AJAX won’t upload featured image – Plugin development
- Load more posts using AJAX based on posts inside WP_Query
- PHP calling AJAX function that relies on passed PHP function values not working
- Where to add my PHP codes for AJAX Jquery to work?
- Adding ELSE argument to AJAX Live Search for “No results found”
- How can i find wrong word in search box and replace with correct word
- How to use wp_ajax_set_post_thumbnail?
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- Can’t make lazy load for my site, help!
- How to reload a php script, using AJAX and jQuery
- Change WooCommerce currency programmatically on AJAX request
- Top Authors list by highest post views with Ajax pagination
- Offset with ajax load more posts duplicates
- Custom theme admin-ajax.php 400 (Bad Request)
- number of posts with “Load More”
- How to send Ajax Call from frontend without using wp_localize_script in Theme
- wordpress more than one ajax request at the same time issue
- PHP drop down menu for my get_category child of
- Ajax not updating to database
- Ajax Load more CPT via shortcode
- MySQL query in WordPress with AJAX
- Registration form not registering First and Last name
- Result from wp_send_json adds line feed
- Is custom behaviour possible when asynchronously uploading?
- Page 2+ of taxonomy archives does not recognise sort-order from dropdown
- Dropdown Menu for Query_Posts
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- Data inserted in database, but ajax calls error function
- Load Meta box value into div AJAX [duplicate]
- Remove Woocommerce product from cart with ajax/fetch
- WooCommerce Modal Fly cart on add to cart – With AJAX
- Word press – JSPDF – Sending PDF as attachment from wp_mail – Special characters
- Upload multiple files via ajax from an HTML file input
- How to pass javascript var to php var
- Ajax infinite scroll random order shows duplicate posts on custom post type