Sounds like the location.reload is happening too quickly as the server is coming up.
Try this:
var exec() as String
exec.Add( "setInterval(function() {" )
exec.Add( " if ($('#dialog_disconnect').length > 0 || $('#dialog_reconnect').length > 0) {" )
exec.add( " $.ajax({url : window.location.href}).done(function(data, statusText, xhr) {" )
exec.add( " if (xhr.status == 200) setTimeout(function() {location.reload();},10000);" )
exec.Add( " });" )
exec.Add( " }" )
exec.Add( "}, 10000);" )
ExecuteJavaScript( String.FromArray( exec, "" ) )