These lines are responsible for the alert:
success: function(data) {
window.alert(data);
},
error: function(errorThrown){
window.alert(errorThrown);
}
In the first block, success, the callback function is executed if the ajax request succeded. The second block, error, will run if the request returned an error.
Right now in both cases an alert is triggered via window.alert() function call. You should replace these calls with your own logic.
To start, replace them with console.log() calls passing the data you’re interested in. Then open your browser’s console and check the data printed there.
If you see 400 error in the console with WordPress, check this answer:
Related Posts:
- How can I fetch loop of post titles via AJAX?
- How build a custom login/register form with error handling?
- Is having multiple theme customizers for different pages possible?
- Where to include php files in wordpress and how to refer to them later [closed]
- Admin Media grid view images won’t load
- Passing JSON data from WP Query into AJAX causing NULL errors
- AJAX / Read More: multiple check_ajax_referer() and wp_create_nonce() not working independentely
- Handling an Ajax form submit
- Ajax call to my WordPress website from an external application [duplicate]
- Validate a users email address when using gmail to register
- Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB
- Use ajax to update_post_meta
- WooCommerce: update custom fields after checkout validation failure
- How to speed up admin-ajax.php in wordpress
- Can I use HTTP POSTs? Is there a better alternative?
- How to make custom total price reactive in navigation
- Put CSS inside a PHP file and include it the right way
- How to test nonce with AJAX – Plugin development
- get current custom post ID by WP_Query method
- Ajax not working es expected (Returns 0)
- Creating a Multi-Level Associative Object Using AJAX
- Ajax category filtering products default show all
- Status 400 for AJAX POST Request with admin-ajax.php
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Why ajax doesn’t work on certain wordpress hooks?
- AJAX pagination, update current page
- adjust section according to country?
- Posting and image insertion problems after EasyApache4 and PHP 7 upgrade
- Ajax call return 404
- How to add a do_action on refreshing of WP customizer?
- how to update and display an option without reloading the page
- Pull GetOption() variable into jQuery dynamically created html
- Load Posts on Click via Ajax into a DIV
- WordPress REST API register_rest_route give a 500 error
- admin-ajax GET response bad request
- Ajax search shows all results when user empties input?
- Why i can’t get custom fields value or post ID via Ajax?
- Post not populating for custom post type based on category selection
- SOAP Request/Parsing XML From wp_send_json_success
- 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
- Proper way to use WordPress function with AJAX PHP file
- Errors being created by admin-ajax.php
- Convert canvas to image and upload image to server
- Live search from database table
- Can’t pass the variable from a select to PHP query
- Add a counter for mouseovers (custom field)
- Accessing an API with jQuery and AJAX
- Ajaxurl suddenly not defined
- How to split AJAX response into two divs
- How to set variables with AJAX request to use in another function in WordPress
- Search Ajax Call – Use Form Data in Response
- Why does PHP called with Jquery AJAX not allow additional php code to be added?
- Deleting records with AJAX, deleting records as I search
- Database entry removed on browser refresh, Ajax PHP jQuery
- Store ajax data in PHP variable
- Ajax result show in console if is called outside function and not showing in array
- How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?
- ajax contact form not submit message
- 400 bad request admin-ajax file upload
- Can’t make lazy load for my site, help!
- Change WooCommerce currency programmatically on AJAX request
- wp_ajax_ 400 Bad Request
- use with class file into wp_ajax hook
- update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
- WordPress AJAX PHP(html) file that is within WordPress Loop
- Why the responseText containing those two arrow signs at the beginning
- WordPress Ajax filter: Create two loops for different output styles?
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Input field duplicates on form submit by jQuery
- Following/Followers Users list Using Ajax Pagination inside Author Profile
- How to call a function from functions.php with ajax?
- Custom theme admin-ajax.php 400 (Bad Request)
- Ajax in a class instantiated via shortcode
- number of posts with “Load More”
- How to send Ajax Call from frontend without using wp_localize_script in Theme
- Include search tags and users in my search results system
- Problem with ajax request and directory structure after site migration
- Apply filters when loading post via ajax
- ajax form with multiple submit buttons and values
- Registration form not registering First and Last name
- Result from wp_send_json adds line feed
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- ajax form function error
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- Load Meta box value into div AJAX [duplicate]
- Detecting IP Address of someone using ‘copy’ function [closed]
- wp_enqueue_scripts with JS script as a string
- How to use url and amin-ajax.php
- WP – Ajax call back data printed in the console.log
- AJAX returning blank result
- AJAX WP_Query’s order and orderby parameters not working
- How can I use AJAX in child theme template?
- Help with AJAX request
- Start a long running PHP process via JS/Ajax and monitor progress on admin page
- custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget
- Trying to GET data with ajax from database and show in fullcalendar