The default response from admin-ajax.php
is,
die( '0' );
…by adding your own wp_die()
or exit()
or die()
after returning your desired content prevents the default response from admin-ajax.php
being returned as well.
It also generally means that your ajax call has succeeded.
Ultimately, to answer your question, it’s meant to work this way. What you are doing by exiting after returning your content is the right thing to do.
Related Posts:
- how to search users by ajax live search
- how to get context information inside my funcion
- WordPress Ajax not returning Response
- wp_ajax add_action fuction won’t fire on custom jQuery action
- Ajax not working to insert, query and result data
- Passing arguments to a admin menu page callback?
- function deactivate_plugins does not exist
- Saving data-URI to media library
- Nonces can be reused multiple times? Bug / Security issue?
- Understanding WordPress functions’ naming conventions
- How-to implement admin Ajax inside an admin WP_List_Table?
- Using AJAX in FrontEnd with WordPress Plugin Boilerplate (wppb.io)
- When is it appropriate to put functions on page template vs. functions.php?
- How can i list current author’s categories?
- How to enable users to down-vote in this simple voting counter (that uses the post meta)?
- Dynamically Override Fancy Title
- Problems with removing admin bar
- Plugin Settings not Saving on Ajax re-ordered table
- Problem with `wp_mail()`
- Calling a function from functions.php in custom page/ blog post
- What is the Difference between directly call a function and call a function using add_action?
- Call to undefined function get_blog_option()
- Timeout on Admin-Ajax?
- Undefined function wp_set_password
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- Plugin Uninstall and Deactivate via Options Menu
- How can I add a CSS rule to edit.php?
- Ensure function has completed before allowing another Ajax call
- add more custom post types and custom role to the code
- How to use WP_Term with (menu) argument in the wp_nav_menu?
- include wp-blog-header not working on MAMP
- Any problem in using native jquery ajax style instead of using admin-ajax.php?
- Show special field when correct shipping is chosen
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- Where can i find wordpress auto update code flows?
- Create a new post using rest api and save featured image using an external image url
- Remove unwanted elements for a wp_nav_menu
- wp.template() returns tags in Ajax response
- Fatal error: Uncaught Error: Call to undefined function get_option()
- template_redirect or admin-ajax.php?
- mysql_real_escape_string() vs. esc_sql() in WordPress
- Checking for existence of a page by title?
- How to modify files inside wp-includes directory in wordpress
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- wp_get_post_terms Order by not working
- AJAX form post returns 0
- Function/Class to list categories with checkboxes
- Bad Request in AJAX
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Ajax submit result opens in admin-ajax.php
- Autogenerate a Table of Contents
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- insert query on a custom table using ajax with jQuery plugin Jeditable
- Plugin AJAX Save to Custom Table
- WordPress multisite,use same cookies across all website?
- Call to undefined function is_home() or any conditional tags
- unregister_setting() vs delete_option() for plugin update
- How to change WooCommerce loop product title HTML output in single product page and archive page
- Setting a JSON web token from a secondary api as a secure cookie on WordPress
- wp_schedule_event is registered but function isn’t running
- Best practice for plugin: always detect admin-ajax call?
- Why is the form not updating when I select a new sector from the list?
- Plugin Form Submitting to admin-ajax.php instead of admin-post.php
- AJAX request not routing through proxy
- Adding tables to dashboard pages programmatically?
- WP 3-way voting system: On to something! Please help!
- Get cat parameter from admin-ajax
- Custom Settings Plugin Save foreach checkboxes
- How to control ajax calls without effecting memory of server?
- function add custom fields to media gallery
- Forbidden Error in ajax call with wordpress
- “add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar
- ajax stopped working when not logged in wordpress
- ajax call return 406 not acceptable for non logged users only
- Does $this context change in an AJAX callback?
- WordPress: I wanted to use Add rewrite rule multiple times for multiple CPT in my plugin
- ajax response strips multidimensional array and unable to decode
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- Inserted data from database does not showing on front-page without referesh page?
- Remove tag from all posts when publishing new post
- wp_ajax function return the html page
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- How To do Ajax In WordPress Custom Plugin?
- foreach argument to get specific file types getting too many returns
- Remove from a div by class name from post page if post author role is not administrator
- WP Ajax on page load not working on bluehost but was working on Godaddy
- WordPress permalink setting
- How can I add recent posts to menu like mashable
- Why is ‘register_activation_hook’ undefined?
- Dynamic banner for use on external sites
- Can’t get query string in ajax call
- Ajax url value to pass ‘variable’ to use in query
- How can i call from custom fields to the category editor?
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- How to plugin function code move to theme function.php ? I’ve tried below code but not working [closed]
- WordPress simple ‘Hello World’ plugin – problems
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?