There’s a simple alternative that sidesteps this issue entirely with a modern and easy to use interface, just use a REST API endpoint!
So lets turn this:
add_action('wp_ajax_nopriv_linked_post_image_grid', 'linked_post_image_grid');
add_action('wp_ajax_linked_post_image_grid', 'linked_post_image_grid');
function linked_post_image_grid(){
echo 'this is return message';
die();
}
Into this:
add_action( 'rest_api_init', function () {
register_rest_route( 'buxbeatz/v1', '/linked_post_image_grid/', array(
'methods' => 'GET',
'callback' => 'linked_post_image_grid'
) );
} );
function linked_post_image_grid( $request ) {
return "this is return message";
}
Now you can visit example.com/wp-json/buxbeatz/v1/linked_post_image_grid
and you’ll get a JSON response of "this is return image"
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
- simple wordpress ajax plugin not working when not logged in
- 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
- How to test nonce with AJAX – Plugin development
- get current custom post ID by WP_Query method
- Ajax not working es expected (Returns 0)
- Load a page into a div with Ajax
- 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?
- Fancybox type popup window that’s not an iframe
- how to update and display an option without reloading the page
- Pull GetOption() variable into jQuery dynamically created html
- Function won’t run onclick using Ajax
- WordPress plugin admin page – using WordPress function in linked php file
- Load Posts on Click via Ajax into a DIV
- Use value from Ajax call in PHP function
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- A $_POST should occur when submit form but is not?
- Shortcode to pull posts
- Ajax search shows all results when user empties input?
- Why i can’t get custom fields value or post ID via Ajax?
- 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
- Errors being created by admin-ajax.php
- Convert canvas to image and upload image to server
- 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
- PHP: How to access db the right way in plugin?
- How to split AJAX response into two divs
- 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?
- Is it possible to access admin-ajax.php using PHP?
- Store ajax data in PHP variable
- Multiple AJAX handler functions conflict in functions.php
- 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
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- 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?
- 400 bad request admin-ajax file upload
- wp_ajax_ 400 Bad Request
- 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
- Cannot transfer ajax post data from js to php file
- 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)
- wordpress dependent dropdownlist using post type is not working
- Input field duplicates on form submit by jQuery
- Following/Followers Users list Using Ajax Pagination inside Author Profile
- How to echo a PHP code into WooCommerce variation product?
- How to call a function from functions.php with ajax?
- Ajax in a class instantiated via shortcode
- Custom Post type Ajax search results
- Ajax wordpress function showing source code in alert and not value of input field?
- Singleton in plugin fails on AJAX call (Plugin initialzed again)
- Problem with ajax request and directory structure after site migration
- Find the method which AJAX GET calls
- Code works on page-example.php by not category-example.php
- Retrieve $_POST data to send to javascript without using localize script
- ajax form with multiple submit buttons and values
- How to run ajax in WordPress Post?
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- Add php function into .js file (for tinyMCE button)
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- WP_Query based on another query on the page
- ajax form function error
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- send meta box input data without publish button
- wp_enqueue_scripts with JS script as a string
- Correct way to perform a GET to another PHP file hosted on wordpress
- How to display inputted data in Ajax without button or click event
- AJAX returning blank result
- using AJAX [object Object]
- Ajax – how to use XMLHttpRequest in wordpress