Jump to content

converting html in echo();


glennn.php

Recommended Posts

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

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?

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...

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!

 

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>

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.