I'm trying to load html into the div's (which ever is empty) but the following code fails to work properly. Instead, it loads html in the same (div1) everytime, overriding previously loaded html.
<div id="Div1" Class="col-sm-3 hidden"></div>
<div id="Div2" Class="col-sm-3 hidden"></div>
<div id="Div3" Class="col-sm-3 hidden"></div>
$.each(chkUnivIDs, function (index, value) {
DisplayUnivInfo(univID);
});
var univID;
function DisplayUnivInfo(tID) {
var chkDiv = ""; univID=tID;
if ($('#Div1').html() == "" && chkDiv == "") {
DisplayIn($("#Div1"));
$('#Div1').removeClass('hidden');
chkDiv = "Not Empty";
}
else if ($('#Div2').html() == "" && chkDiv == "") {
DisplayIn($("#Div2"));
$('#Div2').removeClass('hidden');
chkDiv = "Not Empty";
}
else if ($('#Div3').html() == "" && chkDiv == "") {
Your ajax requests are all submitted when all the divs are empty, so they all populate the first one. Instead, in the success callback, you could just find the first empty div and fill that.
But, as others have written, it's better to make just one ajax call and present it all at once.