Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6582179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:14:53+00:00 2026-05-25T16:14:53+00:00

i can’t get javascript to load 2 text files with regular script or query

  • 0

i can’t get javascript to load 2 text files with regular script or query and i need help, plz give and answer?

heres with jquery,

<script type="text/javascript">
setTimeout(function(){
   window.location.reload(1);
}, 1000);
</script>
<script language="javascript" src="file:///Users/trevor/Desktop/jquery.js" ></script>
<script type="text/javascript">
jQuery.get('file:///Users/trevor/Desktop/x.txt', function(data) {
    document.getElementById('xp').innerHTML = data;
});
</script>
<script type="text/javascript">
jQuery.get('file:///Users/trevor/Desktop/y.txt', function(data) {
    document.getElementById('xp').innerHTML = data;
});
</script>
<p id="xp">hi</p>
<br>
<p id="yp">hi</p>

and without,

<script type="text/javascript">
var client = new XMLHttpRequest();
client.open('GET', 'file:///Users/trevor/Desktop/x.txt');
client.onreadystatechange = function() {
  document.getElementById('xp').innerHTML = client.responseText;
}
client.send();
</script>
<script type="text/javascript">
var client = new XMLHttpRequest();
client.open('GET', 'file:///Users/trevor/Desktop/y.txt');
client.onreadystatechange = function() {
  document.getElementById('yp').innerHTML = client.responseText;
}
client.send();
</script>

and possibly…

<script type="text/javascript">
var x = document.getElementById('x').contentWindow.getElementById('xp').innerHTML

var y = document.getElementById('y').contentWindow.getElementById('yp').innerHTML

function updatex(){document.getElementById(xp).innerHTML = x}

function updatey(){document.getElementById(yp).innerHTML = y}

setInterval( "updatex(); document.getElementById('x').contentWindow.location.reload();", 1000 );

setInterval( "updatey(); document.getElementById('y').contentWindow.location.reload();", 1000 );


</script>
<p id="xp">hi</p>
<br>
<p id="yp">hi</p>

<iframe id="x" src="file:///Users/trevor/Desktop/x.txt"></iframe>

<iframe id="y" src="file:///Users/trevor/Desktop/y.txt"></iframe>  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:14:54+00:00Added an answer on May 25, 2026 at 4:14 pm

    You can use setInterval to load the files periodically. Here’s a little refactoring:

    function loadFile(url, elementId){
        var client = new XMLHttpRequest();
        client.open('GET', url);
        client.onreadystatechange = function() {
          document.getElementById(elementId).innerHTML = client.responseText;
        }
        client.send();
    }
    

    Now you can call this twice, every second:

    var interval = setInterval(function(){
                                 loadFile('file:///Users/trevor/Desktop/x.txt', 'xp');
                                 loadFile('file:///Users/trevor/Desktop/y.txt', 'yp');
                               },1000);
    

    Some notes:

    • This may work from your local computer, but will not work on all browsers, and definitely not work once (/if) the page is on a server.
    • Since the calls are asynchronous, it is possible the response to an old call will return after a newer one. You may want to keep old clients and cancel them.
    • If possible, an alternative is to use <iframe>s, and simple refresh them periodically.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can i get the source code for a WAMP stack installer somewhere? Any help
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can I get a 'when to use' for these and others? <% %> <%#
I have a bunch of posts stored in text files formatted in yaml/textile (from
Can anyone recommend a fast way to sort the contents of a text file,
Can anybody please tell me how to get ReSharper to replace multiple instances (instead
Can anyone help me trying to find out why this doesn't work. The brushes
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can you reorder SQLite table columns via a query? I would prefer a query
Can I set a label (text) in popup menu (gtk.Menu) but without hovering effect,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.