JSFiddle - React, Tailwind, and code Playground

by Brett Gaynor

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<div class="modal fade" id="printerInfoModal" role="dialog" aria-labelledby="mainModalLabel" aria-hidden="true">
  <div class="modal-dialog fade in">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">
          <asp:Label ID="lblModalTitle" runat="server" ClientIDMode="Static" Text=""></asp:Label>
        </h4>
      </div>
      <div class="modal-body">
        <iframe src="" id="modeliframe" style="zoom:0.60" frameborder="0" height="250" width="99.6%"></iframe>
      </div>
      <div class="modal-footer">
        <button id="btnCloseModal" class="btn btn-info" data-dismiss="modal" aria-hidden="true" aria-label="Close">Close</button>
      </div>
    </div>
  </div>
</div>
<script>
  // Get a list of printers and for each get its status, printer property includes IP address
		
  try {
		const json = mockData({ answer: 42 });
    console.log(json);
  } catch (error) {
    console.log(error);
  }
  
  if (response !== "") {
    jResponse = JSON.parse(response.d);
    $.each(jResponse, function(index, value) {
      var printer = value;

      $.ajax({
          type: "POST",
          dataType: "json",
          contentType: "application/json; charset=utf-8",
          url: "Services/ps.asmx/GetPrinterStatus",
          cache: false,
          data: JSON.stringify({
            PrinterHostnameIPAddress: printer.IPAddress
          })
        })
        .done(function(result) {
          if (result !== "") {
            var printerIP = 'http://' + printer.IPAddress;
            //var redir = 'openInfo("' + printerIP +...

JavaScript

// this function is hit if I copy/paste the html of the the link/button and click it; otherwise it is not called
$('.extLink').click(function(e) {
  debugger
  e.preventDefault();
  var frametarget = $(this).attr('href');
  //clearIframe();
  targetmodal = '#printerInfoModal';
  $('#modeliframe').attr("src", frametarget);
});

function blah() {
  debugger
  var frametarget = $(this).attr('href');
  targetmodal = '#printerInfoModal';
  clearIframe();
  $('#modeliframe').attr("src", frametarget);
}

function blah(frametarget) {
  debugger
  //var frametarget = $(this).attr('href');
  targetmodal = '#printerInfoModal';
  clearIframe();
  $('#modeliframe').attr("src", frametarget);
}

function clearIframe() {
  var iframe = $('#modeliframe');
  var html = "";

  iframe.contentWindow.document.open();
  iframe.contentWindow.document.write(html);
  iframe.contentWindow.document.close();
}