If you import XML through AJAX, you only need a few key things ...
1.) The parent-most element requires an XML namespace ...
<div id="ajax_search_result1" xmlns="http://www.w3.org/1999/xhtml">
2.) Use standard W3C methods (appendChild, importNode, responseXML) and NOT patented Microsoft methods (innerHTML, responseText), or your application will be considered as notepad text instead of a real application. Here's what the code looks like ...
if (window.XMLHttpRequest) {var xmlhttp = new XMLHttpRequest();} else if (window.ActiveXObject) {try {xmlhttp = new ActiveXObject('Msxml2.XMLHTTP')} catch (e) {try{xmlhttp = new ActiveXObject('Microsoft.XMLHTTP')} catch (e){}}} xmlhttp.open('GET',url,true); xmlhttp.send(null); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState=='4') { var xmlDoc=xmlhttp.responseXML; document.importNode(xmlDoc.getElementsByTagName('div')[0],true),id_container_obj); }
Using the correct code, you will not have problems importing XHTML. For a live demonstration, visit my site in my profile, and then click on the site settings in the upper right corner.
source share