var processor = new XSLTProcessor(); function updateResults(ele) { var xhReq = new XMLHttpRequest(); xhReq.open("GET", "search.php?query=".concat(ele.value), false); xhReq.send(null); var xhReq2 = new XMLHttpRequest(); xhReq2.open("GET", "stylesheet.xsl", false); xhReq2.send(null); var xmlDoc = xhReq.responseXML; var styleSheet = xhReq2.responseXML; var target = document.getElementById("searchresults"); processor.importStylesheet(styleSheet); target.innerHTML = ""; target.appendChild(processor.transformToFragment(xmlDoc, document)); }