I want jQuery to periodically load a text file located on my server into a div called testMonitor
<script type="text/javascript">
$(function () {
$('#testMonitor').everyTime(500, function (i) {
var file = '/testsite/test_1.0/stream.txt';
$.get(file, function (data) {
$('#testMonitor').text(data);
});
});
});
</script>
When I navigate to testsite/test_1.0/stream.txt in my browser, I see the text file in all its glory so the file is not missing/broken… but my div shows up completely empty. I’ve browsed through almost all the questions on SO related to loading a txt/html file in JS/jQ but nothing has worked. Any ideas?
EDIT: everyTime derives from the jQuery timer plugin. This isn’t broken in and of itself, because I have tested the sample code for everyTime in my div and it does indeed behave as expected.
In your browser you are accessing url from below
in script you are accessing
with the slash in front, just update location into real one and it will work.