mnet fix enclosed

Monkey Forums/Monkey Programming/mnet fix enclosed

c.k.(Posted 2012) [#1]
I had to change the "Get" function in "mnet.html5.js" to the following in order to stop "undefined" from being returned from the function:

MNet_Http.prototype.Get = function( url, timeoutConnection, timeoutSocket )
{
  try
  {
    var client = new XMLHttpRequest();
    client.open( "GET", url, false );
    client.send( null );
    _httpResponse = client.responseText;
    return _httpResponse;
  }
  catch( e )
  {
	  _httpResponse = "";   // <-- here's the new code
	  return _httpResponse; // <-- easier to have this?
  }
}


Fixes my problem, but don't know if it's the optimal solution.


Xaron(Posted 2012) [#2]
Thanks for that! Will check it in.


Goodlookinguy(Posted 2012) [#3]
Wouldn't it be a bit cleaner to only return once. The other way seems a bit redundant.

MNet_Http.prototype.Get = function( url, timeoutConnection, timeoutSocket )
{
	try
	{
		var client = new XMLHttpRequest();
		client.open('GET', url, false);
		client.send(null);
		
		_httpResponse = client.responseText;
	}
	catch( e )
	{
		_httpResponse = '';
	}
	
	return _httpResponse;
}



Xaron(Posted 2012) [#4]
Yes.