Forum Moderators: open
<script>showReply()</script> in my PHP page, but it doesn't work. I also tried calling the 2nd ajax function within the first function's javascript, but that loads the entire website w/in the website. Here's the two fucntions: function submitReply2(objID,msgID) { //make reply
var obj = document.getElementById(objID);
//var thismsgID = msgID;
xmlhttp.open("POST","?submitReply2");
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
obj.innerHTML = xmlhttp.responseText; //use for debugging
}
}
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send('subnum='+msgID+'&opinionID='+document.replyaddform.opinionID.value+'&replytitle='+document.replyaddform.replytitle.value+'&replytext='+document.replyaddform.replytext.value);
return false;
}
function showReply(objID,msgID) {
var obj = document.getElementById(objID);
//var thismsgID = msgID;
xmlhttp.open("POST","?showReply");
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
obj.innerHTML = xmlhttp.responseText; //use for debugging
}
}
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send('msgID='+msgID);
return false;
}
echo "<br><strong>Reply Submitted.</strong><a href=\"?\" onclick=\"return showReply('quote_reply_container_".$opinionID."','".$opinionID."')\">Refresh Link</a>";
echo "<script>setTimeout(showReply('quote_reply_container_".$opinionID."','".$opinionID."'),2000);</script>";
which results in the folowing sent to the page (i checked w/Firebug):
<script>setTimeout(showReply('quote_reply_container_103','103'),2000);</script>
The link works, but it doesn't execute the Javascript. Just to test it i tried doing:
echo "<script>alert('hi')</script>";
but still didn't work.
You actually need to do DOM construction.
Here are a couple of threads you might want to look at: