Reputation: 3003
How to load an page instead of http.responseText
document.getElementById("content").innerHTML = http.responseText; // works
document.getElementById("content2").innerHTML = "test"; // works
document.getElementById("content3").src = "dir/file.txt;"; // how display file.txt content.
the file.txt path is at the same location as javascript. [web sever]
Upvotes: 0
Views: 1561
Reputation: 5050
With jQuery, you could just do:
$("#element").load("file.txt");
All you need to do is download the jQuery js file and put it on your webserver, then include it at the top of your page:
<script src="jquery.js"></script>
...this is assuming your file is server side. It's not possible if it's a client-side file you want
Upvotes: 1
Reputation: 11669
I don't think you can do that through JavaScript directly, you'll have to do it server-side...
Upvotes: 3