2016-05-22 106 views
0

我的代碼中存在一個問題,導致模型的主體內容重複每次我點擊按鈕顯示重複任何人都可以幫助我嗎?身體內容模態內容重複

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 
}; 

回答

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};