0
I have the following code snippet which basically via a request jQuery
($.ajax()
), uses selectors to search for elements of a page (with content) and places within elements of the current page using selectors of this page.
$.ajax({
url: '/system/json/study/radar/uf-panorama-brasil.php?estado=' + this.sigla,
success: function (data) {
//retorna a tabela de #id natureza
var natureza = $(data).filter("#natureza");
$("#uf-natureza").html(natureza);
//retorna a tabela de #id segmento
var macrossegmento = $(data).filter("#macro");
$("#uf-macro").html(macrossegmento);
//retorna tabela de #id federal
var federal = $(data).filter("#federal");
$("#uf-programa-federal").html(federal);
//retorna tabela de #id estadual
var estadual = $(data).filter("#estadual");
$("#uf-programa-estadual").html(estadual);
//retorna tabela de #id municipal
var municipal = $(data).filter("#municipal");
$("#uf-programa-municipal").html(municipal);
}
});
Everything works perfectly. My question is this: is there any more elegant way to write this snippet of code? Because in the part that returns the result the code snippets are repeating.
I will adopt your answer! Thank you!
– StillBuggin