tags:

views:

212

answers:

2

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]

+3  A: 

I don't think you can do that through JavaScript directly, you'll have to do it server-side...

Valentin Rocher
Yes this is correct - browsers can't access files on the client machine
Graza
yes i know that, and im not trying to access the client machine
Power-Mosfet
+1  A: 

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

Graza
sorry but this not what want.
Power-Mosfet
No problems - you still haven't clarified whether you are trying to load a file from the user's machine (client) or the webserver
Graza