Reading a text file with XML in it for web player, crashes web player.

Ive been trying to work on some code to read a text file in from the server that the webplayer is hosted on but it keeps crashing the web player, even though it works on the editor and standalone.

private void GetNextWave()
    	{
    		if(waveNo > wavesInLevel)
    		{
    			Win();
    		}
    		else if(waveNo > 0)
    		{
    			
    				string file = "http://123.456.789.111:80/Waves/" 
                                   + filePrefix + waveNo.ToString() + ".txt";
    				
    				WWW request = new WWW(file);
    				
    				while(!request.isDone)
    				{
    					SetMessageBox("loading");
    				
    				}
    				
    				currentWave = new Wave(request.text);
    			
    		}
    		else
    		{
    			
    			waveBreakTime = Time.time + breaktime;
    		}
    	}

this is the code that i am using, and works for the editor and standalone, but it isnt liked by the web player i believe because of the potentially infinite loop?

so i attempted to use an method with the IEnumerator interface, but im not sure exactly how to get it to work properly.

    public IEnumerator getWaveWeb(WWW request)
    	{
    		
    			
    		if(request.isDone)
    		{	SetMessageBox("loaded");
    			currentWave = new Wave(request.text);
    			yield return request; 
    		}
    		else
    		{
    			SetMessageBox("not loaded");
    			
    			yield return new WaitForSeconds(2.0f); 
    		}
    				
    	}

    private void GetNextWave()
    	{
    		if(waveNo > wavesInLevel)
    		{
    			Win();
    		}
    		else if(waveNo > 0)
    		{
    
  		        string file = "http://123.456.789.111:80/Waves/" 
                                      + filePrefix + waveNo.ToString() + ".txt";
    
    				
 			WWW request = new WWW(file);
  			StartCoroutine(getWaveWeb(request));
    							
    			
    		}
    		else
    			waveBreakTime = Time.time + breaktime;
    		}
    	}

i THINK im on the correct path with replacing my while loop with a coroutine, which sucks cause the other way works fine with the standalone and editor as said :frowning:

turns out i was on the correct track, after several hours of nutting it out it finally works

public IEnumerator getWaveWeb(WWW request)
	{
					
		while(!request.isDone)
		{
			SetMessageBox("not loaded");
			
			yield return new WaitForSeconds(2.0f); 
		}
		
		if(request.isDone)
		{	SetMessageBox("loaded");
			currentWave = new Wave(request.text);
			yield return new WaitForSeconds(2.0f);
		}
		
				
	}
	
	private void GetNextWave()
	{
		if(waveNo > wavesInLevel)
		{
			Win();
		}
		else if(waveNo > 0)
		{

				string file = "http://123.456.789.111:80/Waves/" + filePrefix + waveNo.ToString() + ".txt";
				
				WWW request = new WWW(file);
				StartCoroutine(getWaveWeb(request));

		}
		else
		{

			waveBreakTime = Time.time + breaktime;
		}
	}