Untested but …
You need to pass your “action” identifier with the data, like so:
var data = {
'action': 'my_action',
'whatever': 1234
};
In your case, that action would be get_number_of_promos
.
The example is from the Codex page about AJAX, which you should read carefully: https://codex.wordpress.org/AJAX_in_Plugins
Related Posts:
- Admin Notification after save_post, when ajax saving in gutenberg
- Detecting post type within init action
- wp_ajax_[service] returning 0
- Is there a hook that fires before an ajax call?
- wp_ajax action is not running
- Conditional action hooks
- Is there a hook to process a backbone restful PUT request inside wordpress?
- Can I fire an add_action hook inside of a function that recieves data via wp_ajax?
- WordPress Ajax Problems
- Which allowed API hooks work to add wp_ajax action?
- Using admin-ajax prevents regular php form submission
- ajax problem – function on server is not called
- change wordpress pagination url after doing the request
- Refresh Gutenberg with JS for it show updated post
- Set cors header for ajax requests
- Is there a hook that fires after an ajax call?
- Content including hooks inside wp-settings.php are being called twice in WordPress
- Hook after all metadata are set is triggering several time
- Call public static method from ajax ‘wpcf7_mail_sent’ hook
- Why function called by admin-ajax executes synchronously?
- WordPress blocking polling request when signed into Admin
- At what stage does wp_ajax hooks gets applied during WordPress request?
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- JavaScript implementation of Gzip
- WordPress AJAX with Axios
- Why might a plugin’s ‘do_shortcode’ not work in an AJAX request?
- Get Previous & Next posts by Post ID
- Nonces and Cache
- REST API endpoint for elasticpress autosuggest
- ajax – why multiple calls to wp_create_nonce() return same value?
- Using ajax on categories and wordpress loops
- How to modify wp_ajax function?
- Turn jQuery.ajax() request into XMLHttpRequest (vanilla JavaScript)
- wp_remote_get() to get AJAX url /wp-admin/admin-ajax.php
- Can’t seem to get wp_localize_script to work
- Ajax – gettext without a plugin
- update_user_meta doesn’t work with AJAX
- Ajax stops working when logged in?
- WordPress ajax get content post id
- Using wp_handle_upload and media_handle_sideload with ajax
- Create Page With wp_insert_post() and AJAX
- Load ajax if is_home()
- How to know what page is calling admin-ajax.php?
- Populate a Map at The Same Time as showing Posts via AJAX
- wp_localize_script not working on ajax response
- Get wp_title wp ajax
- Why Does WordPress not output admin-ajax.php path by default?
- Ajax custom search not functioning as expected
- Jetpack Infinite Scroll – Add more than 7 posts each time?
- Speed/Performance difference between `wp_ajax` and `init` checks for AJAX/POST requests?
- Test WordPress api with postman
- Remove trailing 0 from function that is used both statically and dynamically
- How to load next and previous posts by Ajax
- Update attachment metadata fails
- Nonce fails on ajax save
- how to make custom ajax handler?
- WordPress ajax works on FF but not on IE & chrome
- Disallow second login session
- WordPress P2 live problem
- All AJAX requests return a 400 error
- Unable to successfully verify nonce
- POST Ajax bad request
- Getting a variable using $post ajax back from php to js response in WP
- AJAX Call – Failed to load resource: the server responded with a status of 500 (Internal Server Error)
- WordPress is Not Setting PHP $_POST on Custom Ajax
- bulk update meta value with ajax
- javascript ajax and nonce
- Chained ajax call, second call returns 0
- How to create a form button that executes a function?
- Distinguish between 2 instances of admin-ajax.php
- How to update post with Ajax (no plugin)
- Including ‘wp-load.php’ after another include() generates an error
- How to make pages that arent indexed for ajax applications
- edit user input data contact form 7
- WordPress POST AJAX call, var_dump($_POST) NULL and AJAX response empty when inside ob_start
- How to keep scripts persistent during admin-ajax process when saving widget?
- Very weird bug: Ajax for non-admins
- jQuery ajax method does not return data
- WordPress 403 error on form submission with Ajax
- I am getting Admin-ajax.php 400 Error
- Ajax and get_template_part
- How to require files in a custom endpoint
- Load oEmbed iframe within ajax call
- Adding pagination to Ajax Query
- Get post details with pure javascript ajax
- WorddPress website admin part not working correctly – I think ajax/json issue
- check_admin_referer fails on new AJAX plugin uninstall with “Are you sure you want to do this?”
- Ajax Security regarding user priviliges and nonces
- How to populate data from JSON using AJAX in TypeScript? [closed]
- Use ajax without a plugin?
- Know which script/page is being called by ajax call
- Why can wordpress not find the actions I add in my constructor?
- delete attachment for one post without deleting actual attachment post
- wp_editor() in content that was loaded with ajax [duplicate]
- Facebook Pixel + WooCommerce + AJAX = Confusion
- Add “load more” functionality to an AJAX response
- Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php
- Why are the most recent posts not appearing in a fetch request, unless I’m logged in?
- Successful ajax call returns lots of whitespace and text of code with 0
- How to submit a button automatically after every scheduled hours?