to schedule an execution, you can use the window.setTimeout
, to send the data to the server, you can use the XMLHttpRequest
or the $.ajax
.
var dados = { prop1: "Hello", prop2: "World" };
var tempo = 90 * 1000;
window.setTimeout(function () {
var httpRequest = new XMLHttpRequest();
httpRequest.open("POST", urlParaSalvarOsDados, true);
httpRequest.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
httpRequest.addEventListener("readystatechange", function (event) {
if (httpRequest.readyState == 4) {
if (httpRequest.status == 200) {
console.log("Dados enviados com sucesso");
} else {
console.log("Erro no envio dos dados");
}
}
});
httpRequest.send(JSON.stringify(dados))
}, tempo);
You’re probably looking for
setInterval
. But after 1 minute and 30 seconds with respect to what? Some click of the button, another event..– BrTkCa
well the user will watch a video and after 1 minute and 30 seconds watching the video will be sent a function that will add 1 point to this user who will then be able to use these points for other things
– Guilherme Sousa