This is one of those rare times I can proudly say… there isn’t any problem here!
The reason the server is returning with 0
is because I was logged in! The wp_ajax_nopriv_example_ajax_request
is only for users who are not logged in. After logging out this works fine.
So if you are looking to do the same thing, just make sure you have both actions below the function:
add_action( 'wp_ajax_example_ajax_request', 'example_ajax_request' );
add_action( 'wp_ajax_nopriv_example_ajax_request', 'example_ajax_request' );
Related Posts:
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Why is my ajax call refreshing the page?
- How to create popup same as wordpress popup feature
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- Check if email address exists front end with AJAX in a plugin
- Ajax contact form widget plugin data not insert in database
- Ajax request sends url rather than data
- wc_get_template_part doesnt display the content [duplicate]
- WordPress Ajax request “Failed to load resource: the server responded with a status of 400 ()”
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Overwriting Plugin’s Ajax callback function from theme
- WordPress ajax not working in registration
- Ajax, jQuery and WordPress
- How to get site homepage from plugin?
- Load css classes after using ajax calls
- Jquery post responses 500 error after some time and lastly an 503 error
- Ajax response from Media Selection does not update ALL information more than once
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- WooCommerce get_price returning wrong price when used via ajax
- Simple ajax call not working in wordpress plugin
- Form isn’t inserting data into database with ajax plugin
- Best approach to fetch data from wp options to js file or php file
- How to put JQuery/Ajax inside shortcode?
- AJAX search posts and pages
- __callStatic method handler passed to add_action causes bug in PHP
- Using a custom plugin to capture input data via Ajax and PHP
- Best place for if/else piece of code related to custom plugin?
- jQuery for custom plugin not working with Divi theme
- Ajax call returning 0
- Create tabs in admin options page from custom post type loop
- How can I inject options into an select tag inside the widget form?
- Display wordpress post’s in popup?
- How to prevent plugins from loading jQuery
- Using color picker in plugin, does input attribute order matter?
- Post Comments with Ajax in WordPress
- Create shortcode to echo javascript
- how to insert data in wordpress table usnig jquery ajax
- What are the Best Practises When Using AJAX in Plugin Development?
- Admin AJAX doesn’t work in plugin admin page – Even though code is copied verbatim from WordPress Codex
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Submit Form data to another page via Ajax (WordPress Way)
- How to add an element right after the article using jQuery?
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- wordpress add_action() issue in ajax call
- How to display checked posts on another page over AJAX? (like comparasion style)
- WordPress front end AJAX. Return 0 :?
- Using WordPress to build membership Page
- Save user total active time after login in wordpress [closed]
- Asynchronous request in wordpress
- How do I make sure that my plugin only runs on article detail pages?
- Is there a better way of handling AJAX requests in WordPress?
- WordPress API functions not working at AJAX functions.php call
- How to include my Ajax calls in one function instead of calling different ones every time?
- Calling a class method instantiated by ajax call in wordpress [closed]
- jQuery code didn’t run on my plugin
- The Events Calendar Plugin – List View Background Colour Issue [closed]
- Using AJAX to run SQL statement and populate dropdown
- Adding a jQuery modal dialog to the admin area
- best way to run a php script away from the template?
- can’t unzip file
- Pass PHP variable to javascript
- wp_query ‘s’ parameter does not work with WC_AJAX
- Jquery POST Ajax Return null data in wordpress
- How do I reinit WordPress plugins dynamically using jS?
- Error datatable whit ajax
- WP Ajax DB issues
- Cannot pass value variable to WP AJAX functions
- How to properly enqueue jQuery knob on WordPress without conflict?
- Ajax Call not Working in Plugin
- jQuery Ajax not loading page with ACF fields
- JS working when used normally but not in wordpress
- update_post_meta is not working for me when I use e.preventDefault for update button
- How to use Datatable with Ajax when creating plugin on WordPress?
- AJAX update fails for public/non-admin users
- checkout stripe with plugin contact form
- WordPress Thickbox Navigation Issue in Gallery
- Dynamic input fields in WordPress Plugin
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Overwrite js code using WP_Footer
- Not displaying Woocommerce product page in lightbox
- ajax voting for custom post type
- Storing Array of values into wordpress options
- Help with customising love it plugin (use within foreach)
- My ajax request don´t work and return 0
- WordPress environment not loading properly
- wordpress ajax pagination object value does not change
- Can’t find variable is_single in my jQuery plugin
- How can I use wp_ajax_response for front-end error reporting?
- Javascript in plugin not working
- WordPress Feedback popup with date saved into table
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Not getting result using ajax on wordpress
- How to Add Jquery FullCalendar in wp plugin in admin
- What’s the preferred method of writing AJAX-enabled plugins?
- AJAX doesn’t pass variables to the php function in the plugin
- How to add jquery to my custom post type wp plugin
- Like/Dislike Bar not working when updating
- Hyperlink to execute PHP
- WordPress plugin ajax post parameter
- get_option include in my adsense