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
- What’s the preferred method of writing AJAX-enabled plugins?
- Pass PHP variable to javascript
- Help making my pagination plugin better
- Handling jQuery Component Collision
- How to pass JavaScript variable to PHP in wordpress widget?
- Is dynamic forms/entries possible in Widget?
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Editor not displaying dynamically after clicking on the button
- jQuery AJAX call not executing in Plugin
- How to fetch serialized data from wordpress options
- Errors while using ajax from external wordpress page
- Built in admin ajax hooks?
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- how to use ajax to display from database and load more in wordpress plugin
- Get image URL from media library in input
- Ajax with jQuery UI dialog not working
- jQuery function didn’t work in my plugin
- jQuery Plugin to use WordPress functions in AJAX request
- Handling jQuery Component Collision
- $wpdb working with ajax but showing ajax error instead of success
- WooCommerce get_price returning wrong price when used via ajax
- Best approach to fetch data from wp options to js file or php file
- AJAX search posts and pages
- Using a custom plugin to capture input data via Ajax and PHP
- Best place for if/else piece of code related to custom plugin?
- 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?
- 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?
- 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?
- wordpress add_action() issue in ajax call
- How to display checked posts on another page over AJAX? (like comparasion style)
- Using WordPress to build membership Page
- Save user total active time after login in wordpress [closed]
- How do I make sure that my plugin only runs on article detail pages?
- 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?
- 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?
- 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?
- Cannot pass value variable to WP AJAX functions
- How to properly enqueue jQuery knob on WordPress without conflict?
- 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
- 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)
- WordPress environment not loading properly
- wordpress ajax pagination object value does not change
- 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
- 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
- get_option include in my adsense
- Help me with my first very basic plugin
- Ajax in Plugins: returns the whole page
- Ajax button “Load more” is not loading correct language version posts for logged out users
- Inline AJAX script passing variables to PHP
- wordpress admin-ajax bad request 400