javascript - JQuery display XSLT into my html page -
can me please? trying display result of transformed xslt existing page, transformation seem working, it's not displaying results when run html page. have tried run xsl independently , it's seem display correctly on own, leave me jquery.
thank you
this code:
$(document).ready(function(){ displayresult(); }); function loadxmldoc(filename) { var deferred = $.deferred(); var promise = deferred.promise(); $.ajax({ url: filename, type: 'get', datatype: 'xml', success: function(data) { console.log("resolved"); deferred.resolve(data); }, error :function(v1, v2) }); return promise; } function displayresult(){ var xmlpromise = loadxmldoc("my.xml"); var xslpromise = loadxmldoc("my.xsl"); $.when(xmlpromise, xslpromise).done(function(xml, xsl){ if (document.implementation && document.implementation.createdocument) { var xsltprocessor = new xsltprocessor(); xsltprocessor.importstylesheet(xsl); var resultdocument = xsltprocessor.transformtofragment(xml, document); $('#example').append(resultdocument); } else if (window.activexobject) { /* ie */ var ex = xml.transformnode(xsl); $('#example').innerhtml = ex; } }); }