You can’t use 2 echos for an ajax response.
Try this:
js:
$atj.post(MyAjax.ajaxurl, requestData).done(function(result){
console.log(result);
if(result == 'success'){
$atj('.training-form [type=text]').val('');
$atj('.training-form-message').append('<p class="training-form-complete-message">Thank you for the email</p>');
}
});
php
function myajax_submit() {
// snip...
$mail_check = wp_mail( $to, 'Email Test', $message );
remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
if( $mail_check)
echo 'success';
else
echo 'failure';
exit;
}
Related Posts:
- contact form ajax empty response error message
- Wp mail does not work when Ajaxed to
- wp_mail 200 response but no mail sent
- wp_mail doesn’t work when logged in?
- Contact form – ajax, wp_mail
- Add Server Side validation in Ajax mail form
- How to send automatic response after form submission without plugin
- Sending email through Ajax without page refresh hangs on admin_ajax.php
- How to send the checkbox value to email
- Sending email with wp_email and AJAX
- WordPress Ajax JSON success return no being recognized
- Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
- JavaScript implementation of Gzip
- How to cache json with wp-super cache
- 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
- wp_mail script with jQuery post
- REST API endpoint for elasticpress autosuggest
- Admin Notification after save_post, when ajax saving in gutenberg
- Using ajax on categories and wordpress loops
- Cannot load admin-ajax.php. No access-control allow origin*
- Initialize JS with an ajax loaded ACF form
- WordPress Nonce Issue for Ajax Login and Logout
- How to modify wp_ajax function?
- Nonces and Ajax request to REST API and verification
- Vue.js + AJAX Shortcode
- 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
- wp_ajax action is not running
- Ajax – gettext without a plugin
- update_user_meta doesn’t work with AJAX
- How do I set the url to make an ajax request for a html document?
- wp-admin AJAX with Fetch API is done without user
- Ajax stops working when logged in?
- WordPress ajax get content post id
- Using wp_handle_upload and media_handle_sideload with ajax
- Populating content dynamically via AJAX and Advanced Custom Fields [closed]
- Create Page With wp_insert_post() and AJAX
- How to know what page is calling admin-ajax.php?
- Get wp_title wp ajax
- Show Post Content with AJAX
- update_post_meta using ajax
- How to export custom database data to excel file
- How to update Comment post meta through an Ajax call
- ModSecurity && Admin Ajax: Server locking up
- Exposing data using a custom WordPress API
- Bad request 400 from custom ajax call
- Get response for check_ajax_referer
- WordPress ajax-action how to return content
- Custom Login with Ajax not working with IE
- AJAX jQuery post frontend returning failed to load resource status 400
- ajax form is returning the dreaded “[HTTP/1.1 400 Bad Request” and a zero
- 400 Bad Request when sending XHR from React.js to admin-ajax.php
- How to check nonce lifetime value of plugins?
- Making POST request with AJAX returns a 400 error (without jQuery)
- Front end theme options ajax returns 0
- Load image src through Ajax by ID?
- Using get_theme_mod in php ajax form doesn’t work
- PHP session when called wp_ajax_nopriv
- What exactly does ‘authenticated’ mean for wp_ajax_nopriv?
- Use AJAX in a WordPress Plugin to Get Data From Custom Database?
- Custom RPC end-point security best pratice?
- AJAX – SHORTINIT set to TRUE returns blank
- How to make image in TinyMCE clickable
- Ajax mousedown call getting “cancelled” when clicking link
- WordPress Ajax Not Firing
- Get uploaded attachment width & height and attachment ID after upload them
- Uncaught TypeError: Cannot read properties of undefined (reading ‘message’) [closed]
- Refresh checkout fields on add to cart with order bump
- Is it good practice to use REST API in wp-admin plugin page? [closed]
- Ajax not sending the data correctly- Multidimensional array
- get a bad request 400 on my ajax-admin.php file
- How to check Ajax request only when i opened the Notifications list?
- All WordPress AJAX calls always return 0
- Trigger action via button
- how to get password from user instead wp-generate-password
- Class called in template, AJAX not registering
- Same query in category.php and in function.php, but different result
- How to use nonces for frontend AJAX voting if the page gets cached?
- Ajax take too long to return code
- problem when adding wp_editor with ajax [duplicate]
- Get wp-load.php PATH with wp_localize_script and JavaScript for plugin
- Ajax request to admin-ajax.php and window.location.href
- Objects and get_post_meta() gives me 1 string for latitude and longitude
- Why can wordpress not find the actions I add in my constructor?
- delete attachment for one post without deleting actual attachment post
- where does my function output from load-* go?
- WordPress ajax requst returns zero
- wp_editor() in content that was loaded with ajax [duplicate]
- WordPress blocking polling request when signed into Admin
- Facebook Pixel + WooCommerce + AJAX = Confusion
- Send button using own contact form [closed]
- Translating wordpress foreach to ajax
- AJAX loading with custom parameters
- Adding custom fields to Wired Impact Volunteer Management Plugin
- How to update my jquery/PHP function to add/remove user as favorites in (WordPress) users list
- randomly get 400 error while user is logged in wp_ajax