You should not use your own AJAX handler PHP file. Your problem is that your file calls add_action() function and that function is part of WordPress, your file is not loaded in the WordPress context, so that function is not loaded. You need to load WP in your file first.
But, that is not a good way to do this. WordPress already has a dedicated AJAX handler file and you should be using that, and not your own file that might be a security risk.
This is a good article on using AJAX in plugins and it is on official WordPress Codex: AJAX in Plugins.
Related Posts:
- How to load wp_editor via AJAX
- How can I pass a variable to wp_ajax action?
- Loading shortcode with ajax
- Add image to post from external URL
- How to add a sub menu with AJAX?
- Create Proper WordPress Ajax Request in JavaScript, NOT jQuery
- Execute a function using ajax
- Problem running Ajax in WordPress
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- What’s the point of using WordPress’s built in admin-ajax.php?
- Admin-ajax.php is dying “0” without processing function
- How to remove an Ajax action
- Get Plugin Information from Multiple Sites Externally
- How can I reuse the WordPress search form for a custom plugin / widget?
- AJAX image upload with a upload progress bar using media_handle_upload
- jQuery Plugin to use WordPress functions in AJAX request
- Ajax gives 400 error
- Why plugin ajax response is -1?
- WordPress Ajax Callback
- plugin ajax to external php file always return null
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Shortcode button dosent work for all posts. Work for first post only
- When to use action hooks and plugins
- Simple ajax call not working in wordpress plugin
- Form isn’t inserting data into database with ajax plugin
- What’s the best way to implement AJAX in WordPress?
- How to put JQuery/Ajax inside shortcode?
- __callStatic method handler passed to add_action causes bug in PHP
- jquery not calling php function
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Ajax with plugins returns 0
- admin-ajax.php warning max input vars exceeded on layered pop plugins [closed]
- Using AJAX to generate front end / viewer end pages
- Post Comments with Ajax in WordPress
- WordPress api call using wp-ajax returns error 400
- Using wpdb without loading all plug-ins via wp-load.php
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- Render Modula Plugin Shortcode On Ajax Request
- AJAX on Front-End Button Click not working – Custom Plugin
- How to handle WordPress Plugin Front-end AJAX Call [duplicate]
- AJAX Load more start with x posts
- Is it safe to use admin-ajax.php in the frontend?
- Adding inside wp-plugin jQuery script that receives JSON-formatted data, generated by php-function inside this plugin
- WordPress front end AJAX. Return 0 :?
- coding a WordPress AJAX Form using PHP to check if User is Logged Out and Show error
- How to do the simplest possible frontend ajax call from a plugin?
- Asynchronous request in wordpress
- Remove value from array within post meta ajax admin
- How do I localize admin-ajax.php that is used in Ajax Load More – Infinite Scroll?
- Convert to shortcode?
- Is there a better way of handling AJAX requests in WordPress?
- How to get CPT category checkbox list and show post of selected(multiply) checkboxes via ajax?
- Plugin not working locally, but works on server
- Calling a class method instantiated by ajax call in wordpress [closed]
- Using conditional staements to load plugins
- Ajax Call in page theme not working?
- How to implement a plugin featuring foursquare like check-in
- Problem with ajax plugin for refreshing posts
- How to call php file in theme directory from plugin
- can’t unzip file
- wp_query ‘s’ parameter does not work with WC_AJAX
- Jquery POST Ajax Return null data in wordpress
- How can I adjust my function so the page editor still loads in the backend?
- Facing Problem with admin-ajax.php URL – Getting 404 with AJAX call
- WP Ajax DB issues
- Calling PHP function with AJAX
- Ajax Call not Working in Plugin
- jQuery Ajax not loading page with ACF fields
- How to use Datatable with Ajax when creating plugin on WordPress?
- how can I edit the HTML of yith ajax product filter
- How achive serving multiple concurrent Ajax / Rest calls in plugin?
- checkout stripe with plugin contact form
- Ajax response returns html code instead of user data
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Overwriting Plugin’s Ajax callback function from theme
- 504 Timeout gateway when trying to pay for an order in Woocommerce. What else can I do?
- admin-ajax.php not working properly on subdomains
- Help with customising love it plugin (use within foreach)
- My ajax request don´t work and return 0
- Plugin with AJAX on subdomains causes 404 in console
- WordPress update plugin through Dashboard/Plugins displaying error
- display user input using ajax in wordpress
- Ajax, jQuery and WordPress
- Hyperlink to execute PHP
- How to get site homepage from plugin?
- Contact Form loaded with Ajax
- How to load a plugin when doing an Ajax call? [duplicate]
- Ajax Not Working If The Handler is Located Outside Plugin Submenu Page Function
- Build and ajax plugin not work
- WordPress plugin ajax post parameter
- admin panel save option with ajax
- Capturing POST data
- Pulling Advanced Custom Fields from other pages
- Load css classes after using ajax calls
- Advanced Ajax Page Loader and Masonry Grid
- How to create load more button without a plugin?
- How to make a rest style plugin?
- WordPress portfolio pagination on home page
- wordpress Ajax success doesn’t return the value
- Ajax Load More stopped working (Plugin with repeater template, shows hidden Button)