We currently have a python script that uses the Twitter API to generate a text file with a user's latest tweets.
We now need to somehow display them in a webpage, so we attempted to use an XMLHttpRequest to read the local text file and display it. Formatting is not important at the moment, we are just trying to read directly from the file.
The code we have so far, which is mostly from what we found online, is as follows:
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
{
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()
{
document.write("Test. ");
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET","twitterFeed.txt",false);
xmlhttp.send();
}
</script>
</head>
<body>
<h2>Using the XMLHttpRequest object</h2>
<div id="myDiv"></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
Thanks in advance.
EDIT:
The issue we have is that it is not outputting anything, regardless of what is written in the text file. It does print out the "Test. " string that we were using to ensure that the function was being called.
As far as we can tell, there aren't any js or net errors showing up.