title: Work directly with data from AJAX request
body: <p>Within my .NET MVC web project I got this javascript to get data when the user clicks a button.</p>
  
  <pre><code>&lt;script type="text/jscript"&gt;
  
          async function firstFunction() {
              var url = "/Home/CheckPrinter?printer=" + document.getElementById("printerName").value;
              $.get(url, null, function (data) {
                  $("#msgPrinterName").html(data);
              });            
              var e = document.getElementById("ddlViewBy");
              var deviceType = e.options[e.selectedIndex].text;
              var url2 = "/Home/CheckIfValidIP?input=" + document.getElementById("ipAddress").value + "&amp;type=" + deviceType;
              $.get(url2, null, function (data2) {
                  $("#msgIPPort").html(data2);
              });            
              var url3 = "/Home/CheckPrintService?printer=" + document.getElementById("printerName").value;
              $.get(url3, null, function (data3) {
                  $("#msgPrintService").html(data3);
              });
          };
  
          async function secondFunction() {
              await firstFunction();
              console.log($("#msgPrinterName").html());
              console.log($("#msgIPPort").html());
              console.log($("#msgPrintService").html());
  
              // now wait for firstFunction to finish...
              // do something else
          };
      &lt;/script&gt;
  </code></pre>
  
  <p>The data returned will be displayed here:</p>
  
  <pre><code>&lt;div id="alerts"&gt;
                          &lt;p id="msgPrinterName"&gt;
                          &lt;/p&gt;
                          &lt;br /&gt;
                          &lt;p id="msgIPPort"&gt;
                          &lt;/p&gt;
                          &lt;br /&gt;
                          &lt;p id="msgPrintService"&gt;
                          &lt;/p&gt;
                          &lt;p id="msgButton"&gt;
                          &lt;/p&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>The problem I have is that I only get the inner HTML when I click the button twice, but I want to have the data available directly.</p>
  
  <p><a href="https://i.stack.imgur.com/P1lh3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P1lh3.png" alt="enter image description here"></a></p>