xander85 Posted March 25, 2010 Share Posted March 25, 2010 Hi, I'm using a simple Ajax script that grabs some MySQL data, create an XML tag, and displays in a <span> tag. This works fine. However, when I try to pass html code it doesn't work. So I tried the <![CDATA[ tag and when I look at the raw XML output it looks fine: <LaborValue> <type>addons</type> <addons>Add-ons WTD: $600 </addons> <variance>(33.3% <img src='images/up-arrow.png'>)</variance> </LaborValue> However, the image doesn't actual show up on my page. Anything after the <![CDATA[ tag actually shows up. Do I need to send the HTML in a different way to actually display the image? The following is the ajax code that actual displays the xml on the page: document.getElementById("lcvalue_addons").innerHTML=xmlDoc.getElementsByTagName("addons")[0].childNodes[0].nodeValue + xmlDoc.getElementsByTagName("variance")[0].childNodes[0].nodeValue; Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/196439-pass-html-in-xml-with-ajax/ Share on other sites More sharing options...
andrewgauger Posted March 25, 2010 Share Posted March 25, 2010 Javascript: function updateDiv(req){ document.getElementById('divElementIDHere').innerHTML = req.responseText; } from: http://www.quirksmode.org/blog/archives/2005/12/the_ajax_respon.html Quote Link to comment https://forums.phpfreaks.com/topic/196439-pass-html-in-xml-with-ajax/#findComment-1031408 Share on other sites More sharing options...
xander85 Posted March 25, 2010 Author Share Posted March 25, 2010 My response from the server is in XML format, not just HTML. I tried using that but it returns "undefined". Quote Link to comment https://forums.phpfreaks.com/topic/196439-pass-html-in-xml-with-ajax/#findComment-1031411 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.