1
An Ajax request returns some information, among them the data_inicio
and data_fim
of a mandate, but need to display only the dates that are in red, would:
23/12/1936 to 12/12/1944
I need a way to gather and display only them. At the moment I am doing it as follows:
var arr = [];
var per = [];
function printarPeriodo() {
var html = '<br />';
for (var i in per) {
html += '<i class="fas fa-circle fa-xs"></i> ' + per[i] + '<br />';
}
html += '';
per = [];
return html;
}
function addArray(qual) {
var pass = false;
for (var i = 0; i < arr.length; i++) {
if (arr[i] == qual) {
pass = true;
}
}
if (!pass) {
arr.push(qual)
}
}
And using it as follows, within the return of my Ajax:
addArray(json[i].ano_inicio_f);
per.push(json[i].data_inicio_f + ' à ' + json[i].data_fim_f);
That function
addArray
is the same asaddToArray
?– Sam
@Sam Yes, I accidentally changed it at the time of passing. I’ve already edited.
– Guilherme Rigotti