jilo-web/public_html/static/agents.js

21 lines
747 B
JavaScript
Raw Normal View History

2024-09-27 06:49:50 +00:00
function fetchData(force = false) {
// Show loading text
document.getElementById("result").innerHTML = "Loading...";
// Create an AJAX request
var xhr = new XMLHttpRequest();
xhr.open("POST", "index.php?page=agents", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
// Parse and display the result
let result = JSON.parse(xhr.responseText);
document.getElementById("result").innerHTML = JSON.stringify(result, null, 2);
}
};
// Send the AJAX request, with force flag
xhr.send("action=fetch&force=" + (force ? 'true' : 'false'));
}