asset_manager.loadText in JavaScript

I noticed such a problem. When I want to download a resource from assets using this code, I want the code not to be executed until I have downloaded all the data.

  loader = asset_manager.loadText("file", function(callback){ 
    text = callback;
  while( loader.ready == 0 ) {}

This code will never go further than the while loop because the loader.ready variable is always zero.

Any ideas to work around the problem?

Demo >>