Decoma
19-04-2009, 05:11 AM
I created the following parse function so that when I call a page using AJAX, I can still parse the javascript on that page after it has been loaded.
So here's how I have it setup.
function parseJavascript(divid)
{
var code = new Array();
var code = document.getElementById(divid).getElementsByTagNam e('script');
for (n=0; n<code.length; n++){
eval(code[n].innerHTML);
}
}
function AJAXFunctionThatCallsThePage{
blah blah blah blah
the page gets called and successfully is loaded in
to a div that with the id 'test'
parseJavascript('test');
}
Now my I know for sure that the div on my page still has the script tags in it and that they are not omitted, because I used an alert function to alert the div's contents, and the script tags are there after requesting the content. However, the javascript within the div is not parsed after being requested. The javascript is only a simple alert.
Now the parseJavascript(); function works when I use it on a div with content that is not loaded using an AJAX request method. I tested the function by putting some javascript in a "test" div, and then by clicking a link, it initiated the parseJavascript('test'); function. That worked fine. So again, the issue is it will not parse the javascript called by my AJAX request. It just doesn't add up to any reasons.
Maybe there is something very obvious that I am missing...?
So here's how I have it setup.
function parseJavascript(divid)
{
var code = new Array();
var code = document.getElementById(divid).getElementsByTagNam e('script');
for (n=0; n<code.length; n++){
eval(code[n].innerHTML);
}
}
function AJAXFunctionThatCallsThePage{
blah blah blah blah
the page gets called and successfully is loaded in
to a div that with the id 'test'
parseJavascript('test');
}
Now my I know for sure that the div on my page still has the script tags in it and that they are not omitted, because I used an alert function to alert the div's contents, and the script tags are there after requesting the content. However, the javascript within the div is not parsed after being requested. The javascript is only a simple alert.
Now the parseJavascript(); function works when I use it on a div with content that is not loaded using an AJAX request method. I tested the function by putting some javascript in a "test" div, and then by clicking a link, it initiated the parseJavascript('test'); function. That worked fine. So again, the issue is it will not parse the javascript called by my AJAX request. It just doesn't add up to any reasons.
Maybe there is something very obvious that I am missing...?