This is my code that makes a call Ajax:
$(".card").hover(function (event) {
console.log(event)
if (Math.round(event.timeStamp) >= 4000) {
let team_id = parseInt($(this).find("span:first-child").html());
var carta = this;
$.ajax({
method: "POST",
url: "/team/" + team_id,
dataType: "JSON",
timeout: 1000,
error: function (error) {
console.log(error);
},
success: function (res) {
$(carta).append(plantilla_teams(res.id, res.plays_lose, res.plays_win))
}
})
}
}, function () {
if ($(this).has("div.card-detalle")) {
$(this).find("div.card-detalle").remove();
}
})
}
Once the event is activated, in this case it is "mouseEnter", if it passes X seconds in the element, just execute the instructions: