When you need a script to give you useful information in the browser, and the page in question is using AJAX to send information (but not, at the moment, receive information), then (DUH!) use AJAX to give you the information you need!!!
In my case I had a handy editor box in which to plunk the response text from the AJAX request.
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4) {
document.forms["editorbox"].editorBox.value = xmlhttp.responseText;
}
}
At one point, I used
alert(xmlhttp.responseText)
instead of the editorbox, but that wasn't as useful because the alert box doesn't let you select and copy stuff if you need it. Also, my editorbox had a handy-dandy scroll bar, and the errors coming out of my responseText were numerous.In order to make the responseText useful, you may want to echo out certain variables and then
exit;
so that the info you want -- and only the info you want -- will show up where you need it.Now, as to what was actually wrong with the script I was messing with today... It appears that a difference in php.ini files was my problem. In the version of the script that was NOT working, all the quotes were getting escaped as they got soaked up into the PHP script. When I then tried to
dom->loadXML($myXML)
the script was complaining that my XML was no good. Well, of course it's no good, there's all these darned escape characters before the quotes!I don't want to change the php.ini on the server, so I have to get rid of those escapes some other way.
preg_replace
to the rescue!
$pat = '/\\\"/';
$rep = "'";
$myXML = preg_replace($pat, $rep, $myXML);
All better. :)
4 comments:
in Firefox, Tools -> Error Console
lets you copy entire items though, not select specific bits of text.
Would that it were so easy... In this case, the blasted Javascript (The J in AJAX) that I inherited didn't work in Firefox, so I was stuck in IE, which made matters more frustrating for my Mozilla-loving, Web Developer Toolbar worshiping soul.
WOW, you're smart! I'm proud to be chosen to be your friend! Even if it's only for my Hebrew skills.
You are a goofball, Talia, and THAT's why I love you.
כי יום אחד העברית שלי יהיה כל כך טוב שאני לא אצרך מתרגמת בשביל לדבר עם סלקום, ועדיין אהוב אותך!
Post a Comment