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:
- username_exists() function can’t be access without logging in
- WordPress AJAX Pagination with query_posts
- PHP calling AJAX function that relies on passed PHP function values not working
- Looking for a better way to handle an ajax script that pulls in post data on click
- How to add default images into theme customizer image control?
- Can’t use get_results() in ajax query
- Debugging PHP object during Ajax call in WordPress
- WordPress Ajax Data problem
- Problem with WordPress Ajax form
- 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]
- Passing jQuery value using Ajax to a page template
- How to set a custom path, for ajax image upload folder in admin?
- admin-ajax.php responding with 0
- ajax_object is not defined when ajax calls the function
- Page Reloads Before AJAX Request Finishes
- Why is this Ajax not working?
- Ajax return code 400
- get post based on category chosen in drop down – The ajax method
- How to make drop down post title
- Create onClick Event to Re-load a Widget
- ajax, right way to do it and make it works?
- How to store data from multiple forms using ajax and php
- WordPress ajax doesn’t display object method on jQuery .change() function
- Problem with custom plugin using AJAX to pull info from php file
- Gutenberg block – Save PHP function’s output as HTML?
- Call a PHP Function with Multiple Parameters that is outside the AJAX Handler
- Image upload via FormData API and AJAX is not working ($_FILES always empty)
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- WordPress, AJAX and pre_get_posts using conditional tags
- Refresh table data with Ajax
- Setting value of session with Ajax not working
- Ajax contact form return 0
- AJAX – Returning Two JSON Objects with One PHP Function
- unable to use ‘new WP_Query’ in AJAX call
- admin-ajax Firing Error 400 When Logged In
- is_user_logged_in() not working in AJAX validation call
- Add Ajax Hooks and Call from Custom Template PHP
- WordPress Ajax Always returning 0
- Problem with AJAX in wordpress plugin
- How to keep track of when a vote is cast?
- set post limit at load more ajax wordpress
- Woocommerce with Lazy Load php and ajax
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Ajax filter button display all posts
- Can I make get_users() query global?
- Compare $_POST returned values with term array
- How to use AJAX to call php page with parameter
- My jQuery Ajax form submit is still refreshing page?
- Output votes to div dynamically in wordpress
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Incrementing PHP variable onclick to display posts by month
- Processing ajax call to php to insert into mysql database
- calling admin-ajax.php from admin-ajax.php
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- WordPress Custom Add To Cart Button with AJAX
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Display WordPress search results based on the selected Sub-Category
- Using some Loop or repeatable fucntion in AJAX and PHP to reduce repeatability
- jquery & ajax getting data from php in wordpress . admin-ajax.php returns 400
- Settings API form – submit with AJAX
- How do I call a value from the datase using ajax
- Post form – AJAX won’t upload featured image – Plugin development
- PHP calling AJAX function that relies on passed PHP function values not working
- Where to add my PHP codes for AJAX Jquery to work?
- Adding ELSE argument to AJAX Live Search for “No results found”
- How can i find wrong word in search box and replace with correct word
- How to use wp_ajax_set_post_thumbnail?
- register_block_type is not working properly
- Submit remote form to wordpress REST API and save data to custom post type
- WooCommerce REST API AJAX Auth – 401 response
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- AJAX numerical pagination problem in TwentyFifteen-child theme
- How to reload a php script, using AJAX and jQuery
- Filtering custom posts by using checkboxes for taxonomy in an ajax loop always gives server 500 error
- Why my Ajax events are no longer detected after dynamic change of shortcode content
- Contactform7: display results from CURL
- Top Authors list by highest post views with Ajax pagination
- Offset with ajax load more posts duplicates
- ajax polling with admin-ajax.php
- Woocommerce variable products are being added to the card on the homepage (ajax)
- A javascript function that simply runs a php function on the plugin
- Ajax not updating to database
- WordPress 404 when using AJAX to call php function
- how use php query in AJAX jquery
- Ajax Load more CPT via shortcode
- Submitting my form to the database and then redirecting to payment site
- MySQL query in WordPress with AJAX
- wp_delete_comment is doing nothing
- Pass the updated value of aid from form using ajax
- Is custom behaviour possible when asynchronously uploading?
- Execute PHP code in Javascript onclick
- best way to communicate between php and jquery/javascript
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- Data inserted in database, but ajax calls error function
- AJAX: WordPress filters inside $html do not work as intended
- Why not showing all post by default in my jquery filter
- Correct way to perform a GET to another PHP file hosted on wordpress
- Word press – JSPDF – Sending PDF as attachment from wp_mail – Special characters
- Ajax – how to use XMLHttpRequest in wordpress