I have a web site which inserts content via javascript's innerhtml function when a link is clicked (click it again and poof, the inserted data goes away). This works great. When I want to do now is add a flot plot to that injected code. The flot plot needs the javascript to run after it is inserted. Is this possible? The alternate would be a button in the inserted code to then run the JS... but that's not ideal. Thoughts? --Thanks!
Okay.. so here is some code: This first bit is the link that you click:
<a name = "<?php echo $tag_no ?>" class="none" href="#<?php echo $tag_no ?>" title = "<?php echo $tooltip ?>" onClick="sendRequest('GET','/2.0/details.php3?event_no=<?php echo $tag_no ?>&details=0&PHPSESSID=<?php echo session_id() ?>')"><?php echo $concert_date_formatted ?> </a></td>
It calls the javascript functions here:
function sendRequest(method, url){
//alert(method);
if(method == 'get' || method == 'GET'){
http.open(method,url,true);
http.onreadystatechange = function() {
handleResponse(url,method);
}
http.send(null);
} else if (method == "got" || method == "GOT"){
handleResponse(url,method);
}
}
function handleResponse(url,method){
//alert("Junebug!");
if(method == "GOT" || method == "got"){
//document.getElementById(event_no).innerHTML = null;
//alert("got");
BetterInnerHTML(event_no,null);
} else if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
var equals = url.indexOf('=');
var andsign = url.indexOf('&');
var event_no = url.substring(equals + 1, andsign);
if(response){
//alert(response);
document.getElementById(event_no).innerHTML = response;
//BetterInnerHTML(event_no,response);
}
}
}
Which in turn insert the code.