function read( src, callback ) {
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
xhr.onreadystatechange = function() {
if ( this.readyState == 4 && this.status == 200 ) {
xhr.onreadystatechange = null;
callback( xhr.responseText, xhr );
}
}
xhr.open( "GET", src, true );
xhr.send( null );
}
read( 'http://mySite.com/text.txt', function( data ){
alert( data );
});