i click on a button that calls a PHP File over a XMLHttpRequest.
In this PHP File a write a new Javascript Function.
The Result of the PHP File is then loaded on a div container on my first page from where a have clicked the button.
If i click then another button to call the new written Js Function i have no results. (Maybe it isn't defined on that page because of the XMLHttpRequested PHP File)
How can i write this function over a XMLHttpRequested PHP File and call after that this function ???
Thank You for help !!!
here the code from first page:
<html>
<head>
<script type="text/javascript">
function createfunc()
{
if(window.XMLHttpRequest)
{
RNG_Option = new XMLHttpRequest();
}
else
{
RNG_Option = new ActiveXObject("Microsoft.XMLHTTP");
}
RNG_Option.onreadystatechange=function()
{
if(RNG_Option.readyState==4 && RNG_Option.status==200)
{
document.getElementById("phprequest").innerHTML=RNG_Option.responseText;
}
}
RNG_Option.open("GET","create.php", true);
RNG_Option.send();
}
</script>
</head>
<body>
<a onclick="createfunc();">Create Function</a>
<div id="phprequest"></div>
<a onclick="callfunc();">Call Function</a>
</body>
</html>
the php file create.php :
<?php
echo "<script type='text/javascript'>";
echo "function callfunc()";
echo "{";
echo "alert('CALL MY FUNCTION');";
echo "}";
echo "</script>";
?>