如何将jQuery结果附加到Modal窗口并显示HTML而不出现格式问题?

我在MySQL的列中包含原始HTML(仅表标签中的内容),我试图在模式窗口中显示它们。

我已经成功使用jQuery和Coldfusion将数据拉回了。

但是,我不知道如何将这些数据从jQuery附加到模式中,当我尝试在模式中显示HTML时(仅从数据库中复制/粘贴),这会导致其余问题该页面,因为有时数据库中的HTML很乱。

我需要弄清楚如何将我的JQuery响应附加到模式,以及如何确保数据库中的HTML被“包含”在该模式内并且不会影响页面的HTML。

由于我正在使用一些现有代码,因此尝试合并网上发现的内容(包括Dialog)的运气并不好。

编辑:我在模式窗口中添加了ID为“ cs0”的div,并尝试将其附加到Jquery部分。我猜我没有正确地做它的Jquery方面。

模态:

<input id="clickID-#key#" name="" type="button" value="View Modal" />

<div id="modal-#key#" class="modal" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="" >
 <div class="">
    <div class="">
      <div class="modal-title">
         <h2 class="" id="myModalLabel">Case Number: #custom1#</h2>
      </div>
      <div class="modal-body">
        <div id="cs0"></div>
          <img src="" id="clickImage-#key#" style="max-width:800px"/>
        </div>
      <div class="">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

JQuery:

$(document).ready(function() {
    $("##paginatedTable").on("click","##clickID-#key#",function(){
        console.log('#key#');
        var dataSent = {'key':'#key#'};
        $.ajax({
        url: 'inc/_data_ruling_load.cfm',type: 'POST',data: dataSent,success: function (response) {
           var res = JSON.parse(response);
           console.log(response);
           console.log(response);
           $('##clickImage-#key#').attr('src',res.img);
           $('##modal-#key#').modal('show');
           $('##cs0').text('response').dialog();
           console.log(response);
        },error: function () {
            alert("error");
        }
    }); 

    });
});

链接的文件:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="js/jquery-3.1.1.min.js"></script> 
<script src="js/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
menghui1987 回答:如何将jQuery结果附加到Modal窗口并显示HTML而不出现格式问题?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3157733.html

大家都在问