Skip to content

Instantly share code, notes, and snippets.

@J3698
Last active September 9, 2021 19:30
Show Gist options
  • Save J3698/f1c79874dbcd01a0048b2312d1623005 to your computer and use it in GitHub Desktop.
Save J3698/f1c79874dbcd01a0048b2312d1623005 to your computer and use it in GitHub Desktop.
Request predictions
function addClassifyRequestInterval() {
setInterval(function() {
if (!shouldUpdate) {
return
}
shouldUpdate = false;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
let jsonResponse = JSON.parse(xhttp.responseText);
let top5 = jsonResponse['top5'];
updatePredictionsHTML(top5);
}
};
data = encodeURIComponent(JSON.stringify({"data": points}))
xhttp.open("GET", "http://localhost/classify?points=" + data, true);
xhttp.send(null);
}, 150);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment