I have the code below that works, but I need to expand it, so I am attempting to make it more streamlined.
success: function setData(data) {
$("#price" + lastchar).html(data.price);
$("#matricule" + lastchar).html(data.matricule);
$("#tag" + lastchar).html(data.tag);
$("#ins_yr1" + lastchar).html(data.ins_yr1);
$("#Totalacq" + lastchar).html(data.Totalacq);
}
Like this:
success: function (data){
var desc=[];
desc = ["price","matricule","tag","ins_yr1","Totalacq"];
for (var i=0;i<desc.length;i++){
$( "#" + desc[i] + lastchar).html(data.desc[i]);
}
}
But this does not work because it does not accept a variable desc[i] within the .html(), at least not in the format I am trying to do it.
Any ideas? Thanks!