I was trying to display a changing temperature value, in an html file, using the js. But all I got was a blank page. I included the jQuery library in the same directory, in addition to the txt file I was trying to parse. Also tried changing the txt file to a php file like in the original code I got from here.
Apparently there was nothing wrong with my code. So what could be the matter?
<html>
<head>
<title>Auto-Refresh DIV</title>
</head>
<body>
<div id="auto"></div>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready( function(){
$('#auto').load('load.txt');
refresh();
});
function refresh()
{
setTimeout( function() {
$('#auto').load('load.txt');
refresh();
}, 2000);
}
</script>
</body>
</html>
After getting this response from my console:
XMLHttpRequest cannot load file:///C:/foo/load.txt. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource.jquery-1.11.1.min.js...
I tried loading the page through localhost, as this post suggested. But the page was still blank...