I'm kind of new to JavaScript, I know the basic syntax and how it works but I've been hit with this problem that I can't seem to solve...
I use the following code to call a file which gets the RSS feed from one site.
<html>
<head>
<script type="text/javascript">
function showRSS(url)
{
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("rssOutput").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getrss.php?q="+url,true);
xmlhttp.send();
}
window.onload=showRSS("http://www.urlwithrss.com/rss");
</script>
</head>
<body>
<div id="rssOutput">RSS-feed will be listed here...</div>
/*the following line isn't in the code but is what I would like to be able to do
<div id="rssOutput2">Another RSS-feed will be listed here...</div>
*/
</body>
</html>
However I would like to pass as perimeter two separate urls, (both when the page loads) from which the information should be displayed in a different place on the page, not in the same div as above. I've tried several methods of fixing this which I think are best not to mention since my explanations can get confusing but the main problem I seem to come up with was calling the same function twice, it would only execute the last one even if I did window.onload=rssOutput; rssOutput2; where rssOutput2 was a copy of the original function and many other methods suggested online. If anyone can help me in getting this done then it would be appreciated greatly.