Skip to content

Instantly share code, notes, and snippets.

@seanconklin
Created April 7, 2023 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanconklin/bdb33fc9578b8cc26fd671d3798f13bb to your computer and use it in GitHub Desktop.
Save seanconklin/bdb33fc9578b8cc26fd671d3798f13bb to your computer and use it in GitHub Desktop.
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('div.ccom_monitoring_task')
.forEach(function(taskDiv) {
taskDiv.innerHTML = '<img decoding="async" alt="spinner" src="/wp-includes/images/wpspin.gif">';
let task = taskDiv.getAttribute('data-task');
let request = new XMLHttpRequest();
request.open(
'POST', '/wp-admin/admin-ajax.php', true
);
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
taskDiv.innerHTML = this.response;
} else {
alert('Response error');
}
};
request.onerror = function() {
alert('Connection error');
};
var data = new FormData;
data.append('action', 'ccom_monitoring');
data.append('task', task);
request.send(data);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment