I make a $.post
call by sending array of objects (selected values from a checkbox tree) to my API
every time the mouse leave the div where checkbox tree is located. The issue is that the user by moving randomly the mouse could leave and enter the div houndreds of times so that will cause useless $.post
submission without getting new data as the sent content hasn't changed.
Actually here is how the code looks like right now:
$("div.sidebar-wrapper")
.mouseleave(function () {
postPareto();
});
function postPareto() {
$.ajax({
type: "POST",
data: JSON.stringify(config_Array()),
url: "api/prodotti/pareto/",
contentType: "application/json",
success: function (dati) {
tablePareto(dati);
}
});
}
So my question is, is there a way to prevent the $.post
to being submissed if the content hasn't changed or should i just find another approach to submiss the checkbox selection (as it's a checkbox tree i chose to submit data on mouseleave so the user will have some time to decide what to check)?