Hi there,
Ive got a problem where I have JS embedded in a page the Im dynamically included through ajax. Im executing the js in the embedded page by using the eval function.
My problem is I have an onclick event on an element in the embedded page, but when clicking on it, it says it cannot find the function. Here is the relevant code:
Calling Page:
<script>
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var page = xmlHttp.responseText;
document.getElementById("txtHint").innerHTML=page;
var start = page.indexOf('<script>');
var end = page.indexOf('<\/script>');
eval(page.substring(start+8,end));
}
}
</script>
</body>
<input type="input" value="click me" onClick="showHint()">
<div id="txtHint"></div>
Embedded Page:
<script>
function setMe() {
msg = document.getElementById("email").value;
alert(msg);
}
setMe();
</script>
<input type=text name=email id=email value="a@a.com" onClick="setMe();">
Ive got a problem where I have JS embedded in a page the Im dynamically included through ajax. Im executing the js in the embedded page by using the eval function.
My problem is I have an onclick event on an element in the embedded page, but when clicking on it, it says it cannot find the function. Here is the relevant code:
Calling Page:
<script>
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var page = xmlHttp.responseText;
document.getElementById("txtHint").innerHTML=page;
var start = page.indexOf('<script>');
var end = page.indexOf('<\/script>');
eval(page.substring(start+8,end));
}
}
</script>
</body>
<input type="input" value="click me" onClick="showHint()">
<div id="txtHint"></div>
Embedded Page:
<script>
function setMe() {
msg = document.getElementById("email").value;
alert(msg);
}
setMe();
</script>
<input type=text name=email id=email value="a@a.com" onClick="setMe();">