wp_ajax_{my-action}
action hook is only for admin side. For frontend you must use wp_ajax_nopriv_{my-action}
. You can combina both if the ajax action is for both sides. For example:
add_action('wp_ajax_filter_search', 'filter_search_result');
add_action('wp_ajax_nopriv_filter_search', 'filter_search_result');
Also, don’t forget, never, to die or exit at the end of the ajax action because the program is not closed by WordPress on ajax requests, at least you use wp_send_json
family of functions.
add_action('wp_ajax_filter_search', 'filter_search_result');
add_action('wp_ajax_nopriv_filter_search', 'filter_search_result');
function filter_search_result(){
echo 'hello world';
exit;
}
Related Posts:
- How to load wp_editor via AJAX
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Create Proper WordPress Ajax Request in JavaScript, NOT jQuery
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- ‘Lazy loading’ list of posts with pagination
- How to include admin-ajax when loading external javascript
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- How to use wp-ajax in wp-cron
- How to create popup same as wordpress popup feature
- Shortcode button dosent work for all posts. Work for first post only
- WordPress + JavaScipt + AJAX + MySQL: insert query for form
- How to load wp_editor via AJAX
- wordpress add_action() issue in ajax call
- How to get specific string/value from an array? php [closed]
- coding a WordPress AJAX Form using PHP to check if User is Logged Out and Show error
- Ajax call not working in wordpress through a plugin
- Send Array from JS to php file then insert it in wp database through a plugin
- Jquery POST Ajax Return null data in wordpress
- Trouble with AJAX using GET
- Calling PHP function with AJAX
- Ajax Call not Working in Plugin
- JS working when used normally but not in wordpress
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- AJAX update fails for public/non-admin users
- How to disable/enable PHP plugin functionality based on a TinyMCE toggle-button
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Conditional Fields depending on checkboxes
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- How do I convince this button to do something when it is clicked?
- Ajax, jQuery and WordPress
- Load css classes after using ajax calls
- How to make a rest style plugin?
- How do I call an action hook into wp_ajax hook callback function
- Select posts from list and add them in a new list
- How can I make an Ajax login form work with FORCE_SSL_ADMIN enabled?
- Why my browser keeps loading old version of custom JavaScript files in \divi\js? [closed]
- How to pass JavaScript variable to PHP in wordpress widget?
- jQuery AJAX call not executing in Plugin
- I can’t access wordpress functions from an ajax php call
- delete_user_meta Delete one value out of array
- Calling shortcode in wp_localize_script strips result
- Add extra parameter in tag using script_loader_tag
- Insert code after tag without using functions.php?
- Adding with javascript to admin bar. Works in Chrome/Safari, not Firefox
- how to use ajax to display from database and load more in wordpress plugin
- Passing select control value to block
- Reuse javascripts from plugins within the theme
- $wpdb working with ajax but showing ajax error instead of success
- WP-Cufon adding extra space in my paragraphs in Firefox and Chrome
- Why do plugins that cause ‘unexpected output’ create AJAX problems?
- Best approach to fetch data from wp options to js file or php file
- wordpress site | All-in-one-cufon IE Issue
- How to add Internationalization in WordPress using Javascript/React?
- Using a custom plugin to capture input data via Ajax and PHP
- How to get the element ID from new menu list that added with add_filter()?
- Ajax contact form widget plugin data not insert in database
- woocommerce_package_rates not fired when wordpress woocommerce accessed as non ajax
- Modifying a .js Function for Print [QZ Tray, WooCommerce POS]
- AJAX in plugin wp_send_json() sending html
- Is there a standard way to listen for an on change event of a posts featured image
- Ajax Search Lite: Customize Autoscroll
- How to insert HTML/JavaScript form into WordPress page? [closed]
- Create tabs in admin options page from custom post type loop
- GeoMashup plugin: how to customize cluster markers / icons? [closed]
- How can I remove the WordPress-Version (?ver=5.x) from my plugin
- plugin shortcode not working on ajax request call
- Localizing methods for jQuery append prepend wrap parent
- Ajax Plugin Not Echoing Response
- Which plugin can do horizontal scrolling of RSS feeds in WordPress [closed]
- WordPress Ajax code is not Working
- Where Should i write the code for wordpress ajax voting?
- How to include my Ajax calls in one function instead of calling different ones every time?
- how to request a script more than once in wordpress
- How to turn off automatic operation for Nivo Slider?
- Using AJAX to run SQL statement and populate dropdown
- Wp-minify doesn’t seem to minify my JS code
- Need help creating asynchronous data scraper in WordPress
- Ajax 400 error when used inside a plugin
- Strange admin-ajax / CSS / $_SESSION issue
- Cannot run script properly with my custom plugin
- Performing CRUD operations on front end in wordpress
- How to add specific script to WordPress webpage that will working with user input and databases
- Can you add a shortcode to a custom post type that gets the post_title, post_content, etc. and then passes that to a plugin function?
- Add external javascript to post template
- wp-admin/admin-ajax.php 400 (Bad Request) plugin
- Why can I not deregister my style and script on custom post type?
- WordPress Ajax request “Failed to load resource: the server responded with a status of 400 ()”
- Ajax call fails and returns [object Object]
- Adding javascript to header of MetroMagazine theme
- wordpress ajax pagination object value does not change
- Jetpack Comments Change Placeholder Text
- Plugin and javascript placement
- Ajax Not Working If The Handler is Located Outside Plugin Submenu Page Function
- Build and ajax plugin not work
- get_option include in my adsense
- Expanding / Collapsing Modules in WordPress Panel
- Advanced Ajax Page Loader and Masonry Grid
- How to create load more button without a plugin?