PHP snippets intended for shortcode use aren’t going to work here (unless the plugin explicitly offers a solution, in which case ask them).
To properly use AJAX in WordPress you need to put the functions in your child theme’s functions.php file or a simple plugin. Then you need to either:
- Hook the function into the
wp_ajax_
hooks and send your request to/wp-admin/admin-ajax.php
. That’s documented here. - Or create a custom endpoint for the REST API and send the request to your endpoint. That’s documented [here])(https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/).
Related Posts:
- Can I use the same nonce for multiple requests on the same page?
- Real time Duplicate title check
- Load custom field value into div with AJAX
- Jquery ajax to custom php file: returning blank data
- Accessing a random image via ajax
- Data fetch and delete by ajax request
- Making a follow button, Ajax not talking to php
- admin-ajax.php returning error 400 namespaced callback
- Ajax form submit within a Post Metabox
- WordPress File handle – fopen, fwrite not working with $.ajax or $.post Jquery
- Stumped – Ajax Response Returns 0
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- doing an ajax request always outputs 0
- Trying to implement Ajax comments in WordPress, getting WP error
- Can’t search posts using WP_QUERY inside AJAX Function
- Woocommerce add to cart quantity buttons with AJAX
- class click counter save number
- Any possible way to make $wpdb->get_results() return anything else than array?
- wordpress count link clicks by ip address
- Ajax – Call to undefined function get_option()
- Ajax load more posts with multiple tax query
- Ajax call not working
- WordPress Sending data to Ajax with select option
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- Repeating admin-ajax.php not found error in admin
- populate form fields in a loop with ajax
- How to send Ajax request from my plugin in admin dashboard?
- How to pass Select value from Javascript to PHP to generate select option on change
- AJAX success response is not working but it’s saving my changes
- how to make custom ajax handler?
- Plugins not working on AJAX requests
- How to disable controls in theme customizer?
- Get the URL of the page from which an ajax request has been launched within ajax callback
- AJAX button action in foreach
- Unset session variable on page reload / setup but exclude AJAX
- WordPress ajax-action failing because of newline in response
- Making an AJAX call to refresh a table
- load ajax using admin-ajax.php
- Ajax button not working
- Simple AJAX notification when the new post is added to the database
- Short code template + ajax
- Is it possible to create new user from external form using REST API?
- When echo follow Ajax button inside Ajax pagination template not working?
- jQuery Ajax PHP function call returning [object Object]
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Simple jQuery AJAX Request fails to run PHP Script
- Allow user to Upload image and manipulate it on the frontend
- Execute Jquery when a specific page in my plugin is loading
- calling admin-ajax.php from admin-ajax.php
- AJAX function not working [closed]
- what does $options = get_option(‘test_theme’); do?
- Validating an email input from form field before submit using JQuery, AJAX, and PHP
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- jquery & ajax getting data from php in wordpress . admin-ajax.php returns 400
- Settings API form – submit with AJAX
- My Custom Post Type AJAX Query is Returning no posts – why?
- register_block_type is not working properly
- Submit remote form to wordpress REST API and save data to custom post type
- AJAX numerical pagination problem in TwentyFifteen-child theme
- 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
- wp_set_object_terms returns 500 error when called through AJAX function
- How can i send id of the currently posted form data through json response in custom wordpress plugin?
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- autocomplete in wordpress using ajax with json-data
- Contactform7: display results from CURL
- ajax polling with admin-ajax.php
- Remove item from post_meta array via AJAX
- wp_send_json erase last value
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- How to load WP_Editor JS files manually (with AJAX)?
- A javascript function that simply runs a php function on the plugin
- WordPress 404 when using AJAX to call php function
- wordpress ajax pagination
- how use php query in AJAX jquery
- Submitting my form to the database and then redirecting to payment site
- wp_delete_comment is doing nothing
- Pass the updated value of aid from form using ajax
- 403 (Forbidden) delete file image in themer folder
- 500 (Internal Server Error) of external php file
- Use jQuery and AJAX to get HTML
- Problems with plugin that fetches data from database with ajax
- Dynamic Gallery
- Execute PHP code in Javascript onclick
- best way to communicate between php and jquery/javascript
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- AJAX: WordPress filters inside $html do not work as intended
- Why not showing all post by default in my jquery filter
- Jquery autosave text area after typing
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- How to use url and amin-ajax.php
- WP – Ajax call back data printed in the console.log
- How to Set Page Pagination Using Ajax JQuery – WordPress
- How to pass and validate nonce in custom REST routes
- ajax problems on loading page [closed]
- Woocommerce – Include custom user meta in order ‘filter by registered customer’ Ajax search
- AJAX WP_Query’s order and orderby parameters not working
- How can I use AJAX in child theme template?