glennn.php Posted March 24, 2010 Share Posted March 24, 2010 ok, simple question: when i do $string = "<a href=\"page.php\">page</a>"; echo $string; i'm getting the html characters, of course. (might be because i'm using a jquery, or ajax, i dunno, function to return this echo: function refreshIt(divID, MyPage) { xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function(){ if(xmlHttp.readyState == 4) { setInnerText(divID, xmlHttp.responseText); } } xmlHttp.open("GET", MyPage, true); xmlHttp.send(null); return false; } ) i can't figure what function parses these into html format when i call the echo... how can i get this html printed properly? thanks, whomever... G Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/ Share on other sites More sharing options...
gwolgamott Posted March 24, 2010 Share Posted March 24, 2010 Maybe I'm misreading this, but the ajax call is also sending a divID, assuming that is your div for formatting using css why can't u use the style sheet to format it properly? Or is it that you are not get it to echo out at all? Guess just lost on what the problem is? Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/#findComment-1030994 Share on other sites More sharing options...
glennn.php Posted March 24, 2010 Author Share Posted March 24, 2010 because of the AJAX, instead of getting parsed html in the output, page.php linked, i'm getting "<a href=\"page.php\">page</a>". it's occurring to me though that this is an AJAX/xmlhttp problem and not a php problem. my apologies... Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/#findComment-1030995 Share on other sites More sharing options...
shlumph Posted March 24, 2010 Share Posted March 24, 2010 Can you post this JS function: setInnerText() Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/#findComment-1031009 Share on other sites More sharing options...
glennn.php Posted March 24, 2010 Author Share Posted March 24, 2010 here's the whole thing: function getXMLHttp() { var xmlHttp; try { xmlHttp = new XMLHttpRequest(); } catch(e) { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!"); return false; } } } return xmlHttp; } function refreshIt(divID, MyPage) { xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function(){ if(xmlHttp.readyState == 4) { setInnerText(divID, xmlHttp.responseText); } } xmlHttp.open("GET", MyPage, true); xmlHttp.overrideMimeType("text/html; charset=ISO-8859-1"); xmlHttp.send(null); return false; } function setInnerText(divID, response){ var el = (document.getElementById) ? document.getElementById(divID) : document.all[divID]; if(el) { el.innerText = response; } } <LI><A href="#slide-one" onClick="return refreshIt('contentarea1', 'quotes/twain.php')">Mark Twain</A></LI> <div id="contentarea1"></div> thanks! Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/#findComment-1031015 Share on other sites More sharing options...
gwolgamott Posted March 24, 2010 Share Posted March 24, 2010 I wonder if it's sending you xml data back without finding the css file to format it... not getting something like that are you? I mean not getting something as this instead of the html being executed as it should: <?xml version="1.0" encoding="ISO-8859-1"?> - <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/#findComment-1031029 Share on other sites More sharing options...
shlumph Posted March 24, 2010 Share Posted March 24, 2010 Try changing el.innerText to el.innerHTML Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/#findComment-1031032 Share on other sites More sharing options...
glennn.php Posted March 24, 2010 Author Share Posted March 24, 2010 has nothing to do with CSS - the html, "<a href..." should be parsed in the output like page.php instead of being printed verbatim, like "<a href=\"\">page</a>" also, i'm not calling an xml file. this AJAX function is used to call all kinds of files, images, etc... Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/#findComment-1031034 Share on other sites More sharing options...
glennn.php Posted March 24, 2010 Author Share Posted March 24, 2010 Try changing el.innerText to el.innerHTML THAT was it! thanks shlumph! 'preciate both of ya'll responding. Link to comment https://forums.phpfreaks.com/topic/196343-converting-html-in-echo/#findComment-1031037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.