Ever tried jQuery ajax?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$( document ).ready( function ()
{
$.ajax( {
url: "myUrl.php",
type: "GET",
success: function ( R )
{
$( "#IDselector" ).html( R );
},
beforeSend: function ()
{
$( "#IDselector" ).html( "Loading" );
}
} )
} );
</script>
In this, your myUrl.php
file would contain the logic and printing for the reading of the file and the AJAX would handle what to do when complete. (All data in the myUrl.php that you want to see MUST be printed as you would normally for the user to see))
Worth a read into to allow the page to load fully then read in extra data
Also, look into fopen, fread etc. They are useful and better for reading files IMO