Created
April 7, 2023 00:21
-
-
Save seanconklin/bdb33fc9578b8cc26fd671d3798f13bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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