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

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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