Hi, I want to change a title div and a video div when I click on a single link. Right now I have one function that takes two parameters. The parameters are 2 separate txt files that contain the new divs. I want to replace the old divs with the txt files but it only works for the second function. I've searched everywhere but can't find a clear answer. Any help is very much appreciated!
Thanks,
M.
Both functions are meant to do the same thing but they are meant to replace distinct divs with distinct text files. Only the second function works though.
Code:
<script language="javascript">
var videoName;
var videoTitle;
function videoSwitch(videoName){
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)
{
document.getElementById("switch_video").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", videoName + ".txt" ,true);
xmlhttp.send();
}
function titleSwitch(videoTitle)
{
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)
{
document.getElementById("video_title").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", videoTitle + ".txt" ,true);
xmlhttp.send();
}
</script>
Last edited by rootmath; 01-06-2011 at 01:41 PM..
Reason: incomplete response