The issue here is that trace(txtu) is executed immediately after contentLoader.addEventListener(Event.COMPLETE, onComplete), which means it is occurring before the URLLoader is finished loading. So, there is nothing to trace in this situation because it hasn't been loaded yet.
Try calling another function at the end of onComplete(), which will ensure that the external data has fully loaded by that point.
For example:
var contentLoader:URLLoader = new URLLoader();
contentLoader.load(new URLRequest("http://localhost/data.php"));
function onComplete(event:Event):void
{
var txtu:String = event.target.data;
continueWithProgram();
}
contentLoader.addEventListener(Event.COMPLETE, onComplete);
function continueWithProgram():void
{
trace(txtu);
}