You should add wp_die(); at the end of your php function.
But you could also send the response with wp_send_json, wp_send_json_error or wp_send_json_success. These functions also terminate the function execution.
Related Posts:
- WordPress Ajax always returns a 404 error
- Click loads template via ajax
- Display notification only once
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- How to speed up admin-ajax.php in wordpress
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Sending jsPDF documents to the server
- Ajax return code 400
- How to test nonce with AJAX – Plugin development
- class click counter save number
- AJAX request status 200 but no actual “response”
- Save Search System
- dynamic dependent select dropdown
- How to add a do_action on refreshing of WP customizer?
- Setting value of session with Ajax not working
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Fancybox type popup window that’s not an iframe
- How do I Import / Upload Files with jQuery AJAX?
- WordPress Ajax Call inserting data but success response false
- Why i can’t get custom fields value or post ID via Ajax?
- Accessing an API with jQuery and AJAX
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- Admin-ajax.php 404 error
- How to pass values from one function to the other using an array variable
- How to use wp_ajax_set_post_thumbnail?
- Update $wpdb query with AJAX
- AJAX to add to cart multiple products woocommerce
- How to echo a PHP code into WooCommerce variation product?
- How can i get the same ajax result using WP REST API instead of admin-ajax?
- How to call a function from functions.php with ajax?
- number of posts with “Load More”
- Find the method which AJAX GET calls
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- 500 (Internal Server Error) of external php file
- Dynamic Gallery
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- notify users when changed database
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- Retrieve POST data from AJAX call
- JqueryUi Dialog giving Uncaught TypeError: this._addClass is not a function error
- problem with ajax and the path to the php page
- How to use wp_localize_script in a WordPress page other than functions.php?
- Ajax template: how to handle head section
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- Update WordPress Custom Field with AJAX on cached page
- Targeting single page with JS
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Returning a value from a PHP page
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- js file in root loading without
- Checking for new message using AJAX and PHP. Server overload?
- Change “add to cart” button color based on Woocommerce product category [closed]
- Ajax request returns ‘Array’. How to output the actual results?
- Show success or error messages in Ajax response to WordPress custom registration form
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
- Pull GetOption() variable into jQuery dynamically created html
- Error – ‘create_function is deprecated’ [closed]
- Is it save to use eval for a jQuery callback method coming from the database?
- WordPress plugin admin page – using WordPress function in linked php file
- Load Posts on Click via Ajax into a DIV
- A $_POST should occur when submit form but is not?
- Ajax search shows all results when user empties input?
- Get uploaded image and attach it to the new post
- Cannot access $wpdb, comes back NULL
- Admin-ajax php not working on new wordpress version
- Add a counter for mouseovers (custom field)
- Ajaxurl suddenly not defined
- How to set variables with AJAX request to use in another function in WordPress
- How to use wp_send_json() and output the value with ajax?
- Add other class content with reference class value
- Ajax result show in console if is called outside function and not showing in array
- How to change PHP variables with AJAX request in WordPress
- wp_ajax_ 400 Bad Request
- update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
- WordPress ajax filter returning all posts when it should be filtering by category
- wordpress dependent dropdownlist using post type is not working
- Input field duplicates on form submit by jQuery
- Custom Post type Ajax search results
- include javascript Multiple files in wordpress through script.js
- Ajax wordpress function showing source code in alert and not value of input field?
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- Retrieve $_POST data to send to javascript without using localize script
- WordPress AJAX load post metadata in modal
- Add a downloaded JS file to WordPress
- How to call javascript function (jquery) in a shortcode?
- How to run ajax in WordPress Post?
- How can I correctly POST to a WordPress page?
- Add php function into .js file (for tinyMCE button)
- Load php function with AJAX on modal window
- JSON Object Value Show Undefine
- ajax problems on loading page [closed]
- Start a long running PHP process via JS/Ajax and monitor progress on admin page
- Retrive the value of the Active variation of the product and then link it to the “read more” to dynamically change
- custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget
- JQuery UI Autocomplete showing as bullets
- How to make this shortcode not refresh the whole page when i use it on frontend