The problem is that, you have added extra white space before wp_ajax
action. remove space from actions ' wp_ajax_my_action'
and ' wp_ajax_nopriv_my_action'
. because of extra space before ajax request, showing the 400 bad request error.
You should use :
add_action('wp_ajax_my_action', 'my_action');
add_action('wp_ajax_nopriv_my_action', 'my_action');
Related Posts:
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- ajaxurl not defined on front end
- Check for featured image in WP_Query
- add_filter and remove_filter added before and after wp_query
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- WP_LOCALIZE_SCRIPT doesn’t work
- Cannot search post by taxonomy
- WP AJAX is not working, always returns 0
- Can I individually style items in the backend widget list?
- WP_Query returns no results
- Finding posts containing matching array elements in a meta field usign WP_Query
- Any problem in using native jquery ajax style instead of using admin-ajax.php?
- Slow WP_query due to nested wp_query. Need Suggestions
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- How to get Metabox custom field to show checked if value is updated using post meta query?
- Password field is empty when using wp_signon();
- template_redirect or admin-ajax.php?
- Update Data parameter of a wp_localize_script() call
- Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
- Data not insert and update through ajax and jQuery in admin page?
- AJAX button with success callback. (Titan Framework)
- Best practice for plugin: always detect admin-ajax call?
- Adjust query on single
- Get cat parameter from admin-ajax
- WP_Query order posts by category
- Rate limiting ajax requests in WordPress
- Post Pagination does not working on WP-Query
- Can’t get query string in ajax call
- Ajax functions – no access to wp-admin.php only online
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- Loading jQuery library from WordPress admin
- Return custom product in ajax call loop
- Create a custom display order in the main menu
- Fetching the value of forms in WordPress AJAX
- Display content from custom post without modifying the single template
- WordPress add_admin_page not working even parameters are correct?
- Using the default wordpress uploader inside plugin
- Customizer: widget-synced triggers twice
- WordPress not working on localhost
- manage_posts_custom_column, showing serial number using increment in loop
- How to Create Custom HTML Tag on Editor in `Text(HTML)` mode
- Is It Always a Best Practice to Decouple the Frontend from the Admin Area When Developing a WordPress Application?
- Error : “Cannot use object of type WP_Post as array in”
- Modify users.php page to create page/post on button clicked
- Proper way to run wp_query from inside a plugin
- Issue plugin commands in admin settings page
- Can I change header.php of current theme through a plugin function?
- using new WP_Query in save_post function alters $post
- Creating a Link Text like Submit Button in Admin Page
- include wp-blog-header not working on MAMP
- Beginner advice
- maintaing consistent layout wordpress dashboard
- Change the ‘published on’ text?
- Replacing Scripts in Admin Load_Scripts
- How to render a time-of-day string like ’16:42′ with a site’s chosen time format?
- Are block templates incompatible with serialize_blocks?
- WooCommerce get_price returning wrong price when used via ajax
- How to filter users list on user_status field with get_users()
- Programmatically modify an admin page UI of a WordPress site from my WordPress plugin
- Get Current Menu Location inside Nav_Walker
- Show special field when correct shipping is chosen
- Problems with: manage_${post_type}_posts_columns
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- SQL query for custom taxonomy slugs
- Tried in different ways but sidebar not working?
- Can Page Templates be Applied to Archive and Post Templates?
- Global State During an Admin Post
- ORDER BY wp_post custom column name in wp_query
- Short code not working in boostrap modal dont no why?
- Woocommerce checkout update totals with datepicker
- Is there a way to list all actions registered by a plugin or theme?
- Howto: Use Custom Post Types as Submenu Items in Admin
- Including the necessary functions for a custom ajax registration form
- Render content after post title in wp-admin
- How to create database table, add data, update and delete using wpdb via plugins?
- Is there some way to provide the user a list of existing content in a CPT
- On cliking add new post redirect user to a custom page first
- Change the look and feel of admin pages
- How can I rewrite a URL to pass requests to a custom method via AJAX? (I can’t use admin-ajax.php)
- AJAX search posts and pages
- How to localize admin.php only once
- get post attachment using ajax
- Dashboard – get status and position of metaboxes and pass them to ajax method
- Extending theme PHP class in plugin
- How to access noticeOperations from withNotices
- How to hook a custom user function to a wordpress core ajax action?
- Create a new post using rest api and save featured image using an external image url
- how to search users by ajax live search
- WP Gutenberg Blocks – How to limit first/root blocks
- How to get boolean value from register_meta properly?
- What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
- what is the difference between these phares?
- WP_Query filters
- Form doesnt save to database
- Notice: Trying to get property ‘term_id’ of non-object
- Prevent third party plugin’s admin page access based on user type
- How to add WordPress Admin “Insert Link” UI (searches through existing posts for URL) and functionality into a custom plugin?
- Is it possible to restrict all admin pages except theme customisation and storefront using plugin?
- What is the proper method of using global $post?