Skip to content

Instantly share code, notes, and snippets.

@alokstha1
Created May 25, 2021 08:59
Show Gist options
  • Save alokstha1/cc977775b6014ce15beffc7259024753 to your computer and use it in GitHub Desktop.
Save alokstha1/cc977775b6014ce15beffc7259024753 to your computer and use it in GitHub Desktop.
Get ajax action after ajaxComplete on WordPress
jQuery(function($) {
/**
* catch AJAX complete events, to catch wordpress actions
* @param {jQuery.Event} event
* @param {jqXHR} xhr XmlHttpRequest object
* @param {Object} settings options for the AJAX request
*/
$(document).ajaxComplete(function(event, xhr, settings) {
// Specify the AJAX action after which you want to execute your JS
if ("data" in settings && settings.data.indexOf("action=your_ajax_action") != -1) {
// JS Code that runs after the specified WP action
alert(1)
}
});
});
@jackymanovian
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment