I am trying to feed a table with errors we get from a virtual machine, I use json to read the database outputs from the server. Listing one item is fine but If i want to do it for last 5 items of the database, I would repeat the code again and again which doesn't seem any efficient to me. Copy pasting the code below seems unethical :D And I couldn't structure the way I need to use. Function or object. I am open to suggestions.
Edit: copied the wrong block of code :) but it was structured the same so no difference I guess.
$(function() {
$.getJSON("#myURL", function(getStressTestErrorInfo1) {
if (getStressTestErrorInfo2[0] !== undefined) {
var stressTestError1 = getStressTestErrorInfo1[0];
var stressTestErrorId1 = stressTestError1.StresstestId;
var stressTestErrorRunId1 = stressTestError1.StresstestRunId;
var stressTestErrorName1 = stressTestError1.Name;
var stressTestErrorStackTrace1 = stressTestError1.StackTrace;
var stressTestErrorTimestamp1 = stressTestError1.Timestamp;
$('#stressTestErrorId1').text(stressTestErrorId1);
$('#stressTestErrorRunId1').text(stressTestErrorRunId1);
$('#stressTestErrorName1').text(stressTestErrorName1);
$('#stressTestErrorStackTrace1').text(stressTestErrorStackTrace1);
$('#stressTestErrorTimestamp1').text(stressTestErrorTimestamp1);
};
});
});