Here is the end of the javascript which runs when the button is clicked
xmlObj.open ('GET', /ajax.php, true);
xmlObj.send ('');
}
So this executes the php script ajax.php in the root directory:
<?php
echo "<script type='text/javascript'>\n";
echo "var e = document.getElementById('widget_more_');\n";
echo "e.innerHTML += '<p> <a>TEST</a> </p>';\n";
echo "</script>";
?>
Which is a javascript code that searches the html document for the element by id and appends the TEST link to it. I have ran this javascript in the html normally without trying to echo it through php and it works! BUT not when I try to do it through php! What am I doing wrong?
The reason I am doing it this way is because TEST is actually going to be a string from a php variable.
Please advise me.
Thanks.
Better would be:
ajax.php
JavaScript
I don’t really understand why you can’t use a PHP variable.