Issue with multiple simultaneous Ajax Requests

Issue with multiple simultaneous Ajax Requests

Hello,

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.

  1.                 <div id="Div1" Class="col-sm-3 hidden"></div>
  2.                 <div id="Div2" Class="col-sm-3 hidden"></div>
  3.                 <div id="Div3" Class="col-sm-3 hidden"></div>

  1.  $.each(chkUnivIDs, function (index, value) {
  2.                            DisplayUnivInfo(univID);
  3.                        });


  4. var univID;
  5. function DisplayUnivInfo(tID) {
  6. var chkDiv = ""; univID=tID;
  7.  if ($('#Div1').html() == "" && chkDiv == "") {
  8.            DisplayIn($("#Div1"));
  9.            $('#Div1').removeClass('hidden');
  10.            chkDiv = "Not Empty";
  11.          }
  12.         else if ($('#Div2').html() == "" && chkDiv == "") {
  13.             DisplayIn($("#Div2"));
  14.             $('#Div2').removeClass('hidden');
  15.             chkDiv = "Not Empty";  
  16.         }
  17.         else if ($('#Div3').html() == "" && chkDiv == "") {
  18.             DisplayIn($("#Div3"));          
  19.             $('#Div3').removeClass('hidden');
  20.             chkDiv = "Not Empty";          
  21.          }
  22. }


  23.  function DisplayIn(ele1) {        
  24.         $.ajax({
  25.             url: '@Url.Action("Action", "Controller")',
  26.             cache: false,
  27.             async: false,
  28.             data: { id: univID},
  29.             success: function (r) {
  30.                $(ele1).html(r);
  31.                //$(ele1).append(r);
  32.             },
  33.             error: function (r) {
  34.                 alert("Ajax Error: failed to load");
  35.            }
  36.         });
  37.     }