Got the solution:
- Create a PHP file “purge-bb-cache.php”
- Create a JS script like below in functions.php
purge-bb-cache.php
<?php
FLBuilderModel::delete_asset_cache_for_all_posts();
?>
JS script:
// Add JS to customizer
function print_customizer_js() {
?>
<script>
// Purge BB Cache On Save Customizer
jQuery(document).ready(function(){
jQuery("input#save").click(function(){
//var ajaxurl = "<?php echo ( get_stylesheet_directory() . '/wp-content/themes/bb-theme-child/script.php' ); ?>";
jQuery.ajax({
type: 'POST',
url: '/wp-content/themes/bb-theme-child/assets/purge-bb-cache.php',
success: function(data) {
console.log("Purged BB Cache");
}
});
});
});
</script>
<?php
}
add_action('customize_controls_print_scripts', 'print_customizer_js');
Related Posts:
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- WordPress Ajax always returns a 404 error
- Click loads template via ajax
- Display notification only once
- Access/update database with jQuery
- How to speed up admin-ajax.php in wordpress
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Sending jsPDF documents to the server
- Ajax return code 400
- How to test nonce with AJAX – Plugin development
- class click counter save number
- AJAX request status 200 but no actual “response”
- Save Search System
- dynamic dependent select dropdown
- Menu jumping when calling it via PHP
- Setting value of session with Ajax not working
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Fancybox type popup window that’s not an iframe
- How do I Import / Upload Files with jQuery AJAX?
- WordPress Ajax Call inserting data but success response false
- Ajax search shows all results when user empties input?
- Why i can’t get custom fields value or post ID via Ajax?
- Accessing an API with jQuery and AJAX
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Tracking Visitor LatLng with WordPress using JS, PHP. How to put data which was extract using JS into DB
- Admin-ajax.php 404 error
- How to pass values from one function to the other using an array variable
- How to use wp_ajax_set_post_thumbnail?
- Update $wpdb query with AJAX
- AJAX to add to cart multiple products woocommerce
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- How to echo a PHP code into WooCommerce variation product?
- How can i get the same ajax result using WP REST API instead of admin-ajax?
- How to call a function from functions.php with ajax?
- number of posts with “Load More”
- Find the method which AJAX GET calls
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- 500 (Internal Server Error) of external php file
- Dynamic Gallery
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- notify users when changed database
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- Most efficient way to add javascript file to specific post and/or pages?
- Jquery ajax to custom php file: returning blank data
- Looking for a better way to handle an ajax script that pulls in post data on click
- Data fetch and delete by ajax request
- How to add default images into theme customizer image control?
- Can’t use get_results() in ajax query
- WordPress Ajax Data problem
- Passing jQuery value using Ajax to a page template
- Using wp_localize_script to store the template url into a variable to use in JS
- ajax_object is not defined when ajax calls the function
- Page Reloads Before AJAX Request Finishes
- Why is this Ajax not working?
- How to prevent those PHP variables from being cached on WordPress?
- wordpress count link clicks by ip address
- ajax, right way to do it and make it works?
- WordPress ajax doesn’t display object method on jQuery .change() function
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- Ajax random number always the same
- How to send Ajax request from my plugin in admin dashboard?
- [jQuery]Adding shortcode
- Display parent and child taxonomies in separate drop down select fields
- Pull GetOption() variable into jQuery dynamically created html
- Error – ‘create_function is deprecated’ [closed]
- Load Posts on Click via Ajax into a DIV
- 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
- Live search from database table
- Add a counter for mouseovers (custom field)
- Ajaxurl suddenly not defined
- Replacing WordPress Icons (menu,icons32, etc)?
- 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?
- Database entry removed on browser refresh, Ajax PHP jQuery
- Add other class content with reference class value
- Ajax result show in console if is called outside function and not showing in array
- Can’t make lazy load for my site, help!
- wp_ajax_ 400 Bad Request
- update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
- Custom theme admin-ajax.php 400 (Bad Request)
- Automatically refresh page if widget is added to page?
- How to send Ajax Call from frontend without using wp_localize_script in Theme
- Slider from different widgets
- ajax form with multiple submit buttons and values
- Why this plugin is not working?
- Trying to fix multiple category drop down
- ajax form function error
- Load Meta box value into div AJAX [duplicate]
- ajax problems on loading page [closed]
- Start a long running PHP process via JS/Ajax and monitor progress on admin page
- Retrive the value of the Active variation of the product and then link it to the “read more” to dynamically change
- custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget
- JQuery UI Autocomplete showing as bullets
- How to make this shortcode not refresh the whole page when i use it on frontend
- Partial refresh in WordPress live preview