I have a Javascript on my .html page (can’t be asp). From that Javascript I am calling a function in a .js page. The function I’m calling uses AJAX to get a value from an .asp page. This all works fine. I can dynamically replace DIV text on my .html page. So I think this is all working the way it was intended. Now my problem. Instead of replacing the DIV text, I need to set a variable in my Javascript on my .html page. Question 1: Is there a way to set my Javascript variable to my dynamically changed DIV text OR Question2: Is there a way to return the resulting text to set a Javascript variable instead of simply setting the DIV text using .innerHTML when my ready state has changed to 4?
I have a Javascript on my .html page (can't be asp). From that Javascript I am calling a function in a .js page. The function I'm calling uses AJAX to get a value from an .asp page. This all works fine. I can dynamically replace DIV text on my .html page. So I think this is all working the way it was intended. Now my problem. Instead of replacing the DIV text, I need to set a variable in my Javascript on my .html page. Question 1: Is there a way to set my Javascript variable to my dynamically changed DIV text OR Question2: Is there a way to return the resulting text to set a Javascript variable instead of simply setting the DIV text using .innerHTML when my ready state has changed to 4?[/QUOTE]
<script language="JavaScript" src="http://www.dev.lynda.com/htmlOmnitureTracking.js"></script>
[CODE]
OmnitureTracking(); // Are you trying to alter the properties of a div that has not been created yet?
document.write ('<div id="test_pagename">'+pagename+'</div>'); // Created after the call to OmnitureTracking();
s.pageName=pagename // what is the object "s"?
[/CODE]
<i>
</i><html><body>
<script type="text/javascript">
pagename = "This is some text";
function ajax(){
var xmlHttp;
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
<i> </i>pagename = xmlHttp.responseText;
<i> </i> }
<i> </i>}
xmlHttp.open("GET","pagename.txt",true);
xmlHttp.send(null); }
</script>
<script>
ajax();
document.write ('<div id="test_pagename">'+pagename+'</div>');
s.pagename = pagename;
alert(s.pagename);
</script>
</body>
</html>
0.1.9 — BETA 5.19