How to make Javascript Execute after AJAX is called
Okay, on one of my sites I have a "news" sidebar that displays events from a table.

I recently started using AJAX to make the table update by itself.

The AJAX worked for the most part, except for one thing...the time on each event didn't work. I was using JS to display the time.

The following is an example of one event...

    <div class="event">
    <p>The event text</p>
    <script type="text/javascript">
    document.write(get_time(1332900003));
    </script>
    </div>

So the problem is that AJAX grabs the HTML from the table, spits it out, but then the get_time function is not executed:( This worked fine before using AJAX, but not now.

So how can I make javascript execute after it is called by AJAX? I am using this AJAX script...

    function updateNews()
    {
    var xmlhttp;
    
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
	  
	  
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
	  
	  
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
    	if (document.getElementById("news").innerHTML != xmlhttp.responseText)
	    {
        document.getElementById("news").innerHTML=xmlhttp.responseText;
	    }
        }
      }
	  
	  
    xmlhttp.open("GET","display2.php",true);
    xmlhttp.send();
    }
    updateNews();
    updateNews( "showHint()", 5000);

Thanks for the help!:)

How to make Javascript Execute after AJAX is called
===

Okay, on one of my sites I have a "news" sidebar that displays events from a table.

I recently started using AJAX to make the table update by itself.

The AJAX worked for the most part, except for one thing...the time on each event didn't work. I was using JS to display the time.

The following is an example of one event...

    <div class="event">
    <p>The event text</p>
    <script type="text/javascript">
    document.write(get_time(1332900003));
    </script>
    </div>

So the problem is that AJAX grabs the HTML from the table, spits it out, but then the get_time function is not executed:( This worked fine before using AJAX, but not now.

So how can I make javascript execute after it is called by AJAX? I am using this AJAX script...

    function updateNews()
    {
    var xmlhttp;
    
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
	  
	  
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
	  
	  
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
    	if (document.getElementById("news").innerHTML != xmlhttp.responseText)
	    {
        document.getElementById("news").innerHTML=xmlhttp.responseText;
	    }
        }
      }
	  
	  
    xmlhttp.open("GET","display2.php",true);
    xmlhttp.send();
    }
    updateNews();
    updateNews( "showHint()", 5000);

Thanks for the help!:)
