模态内容中的正文内容重复

时间:2016-05-22 13:28:19

标签: jquery html xml twitter-bootstrap xslt

我的代码出现问题导致每次点击按钮显示模型的正文内容重复可以帮助我吗?

function loadXMLDoc(filename) {
if (window.ActiveXObject) {
    xhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
else {
    xhttp = new XMLHttpRequest();
}
xhttp.open("GET", filename, false);
try { xhttp.responseType = "msxml-document" } catch (err) { } // Helping IE11
xhttp.send("");
return xhttp.responseXML;
};

function ShowForm() {

xml = loadXMLDoc("../XSLT/DecForm.xml");
xsl = loadXMLDoc("../XSLT/DeclarationForm.xslt");

if (document.implementation && document.implementation.createDocument) {
    xsltProcessor = new XSLTProcessor();
    xsltProcessor.importStylesheet(xsl);
    resultDocument = xsltProcessor.transformToFragment(xml, document);
    document.getElementById("DeclarationDataDiv").appendChild(resultDocument);
}

$('#myModal').on('show.bs.modal', function (event) {

    var modal = $(this)
    modal.find('.modal-title').text("Declaration Form")

})
$('#myModal').modal('show');

return false
};

1 个答案:

答案 0 :(得分:0)

function ShowForm(){
xml = loadXMLDoc("../XSLT/DecForm.xml");
xsl = loadXMLDoc("../XSLT/DeclarationForm.xslt");

if (document.implementation && document.implementation.createDocument) {
    xsltProcessor = new XSLTProcessor();
    xsltProcessor.importStylesheet(xsl);
    resultDocument = xsltProcessor.transformToFragment(xml, document);
  $("#DeclarationDataDiv").html("").append(resultDocument);
}
$('#myModal').on('show.bs.modal', function (event) {
    var modal = $(this)
    modal.find('.modal-title').text("Declaration Form")
})
$('#myModal').modal('show');
return false};