Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 14061)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -1422,6 +1422,26 @@
 	update_post_meta( $link_id, '_menu_item_url', $link_url );
 
 	die( json_encode($link_id) );
+case 'wpms-upgrade-site':
+	if ( is_multisite() && ! current_user_can( 'manage_network' ) )
+	die( '-1' );
+
+	$site_id = intval( $_POST['site_id'] );
+	$site_url = esc_url_raw( $_POST['site_url'] );
+
+	// Perform a request to update the site
+	$response = wp_remote_get( trailingslashit( $site_url ) . "wp-admin/upgrade.php?step=1", array( 'timeout' => 120, 'httpversion' => '1.1' ) );
+
+	if ( !is_wp_error( $response ) )
+		$result = '1';
+	else
+		$result = '0';
+
+	do_action( 'after_mu_upgrade', $response );
+	do_action( 'wpmu_upgrade_site', $site_id );
+
+	die( $result );
+	break;
 default :
 	do_action( 'wp_ajax_' . $_POST['action'] );
 	die('0');
Index: wp-admin/ms-upgrade-network.php
===================================================================
--- wp-admin/ms-upgrade-network.php	(revision 14061)
+++ wp-admin/ms-upgrade-network.php	(working copy)
@@ -10,17 +10,15 @@
 require_once('admin.php');
 
 if ( !is_multisite() )
-	wp_die( __('Multisite support is not enabled.') );
+	wp_die( __( 'Multisite support is not enabled.' ) );
 
-require_once( ABSPATH . WPINC . '/http.php' );
+if ( ! current_user_can( 'manage_network' ) )
+	wp_die( __( 'You do not have permission to access this page.' ) );
 
-$title = __('Update Network');
+$title = __( 'Update Network' );
 $parent_file = 'ms-admin.php';
 require_once('admin-header.php');
 
-if ( ! current_user_can( 'manage_network' ) )
-	wp_die( __('You do not have permission to access this page.') );
-
 echo '<div class="wrap">';
 screen_icon();
 echo '<h2>'.__('Update Network').'</h2>';
@@ -28,50 +26,145 @@
 $action = isset($_GET['action']) ? $_GET['action'] : 'show';
 
 switch ( $action ) {
-	case "upgrade":
-		$n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0;
+	case 'upgrade':		
+		// Get all the blogs of the site.
+		$blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC", ARRAY_A );
+		$total = count( $blogs );
 
-		if ( $n < 5 ) {
-			global $wp_db_version;
-			update_site_option( 'wpmu_upgrade_site', $wp_db_version );
-		}
-
-		$blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A );
-		if ( empty( $blogs ) ) {
-			echo '<p>' . __( 'All done!' ) . '</p>';
-			break;
-		}
-		echo "<ul>";
+		// Feedback
+		echo '<div id="message" class="updated">';
+		echo '<p><strong>Updating sites <span id="update_site_count">0</span> of '. $total .'</strong></p>';
+		echo '</div>';
+		
+		echo '<ul id="updating">';
 		foreach ( (array) $blogs as $details ) {
-			if ( $details['spam'] == 0 && $details['deleted'] == 0 && $details['archived'] == 0 ) {
 				$siteurl = get_blog_option( $details['blog_id'], 'siteurl' );
-				echo "<li>$siteurl</li>";
-				$response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=1", array( 'timeout' => 120, 'httpversion' => '1.1' ) );
-				if ( is_wp_error( $response ) )
-					wp_die( "<strong>Warning!</strong> Problem updating {$siteurl}. Your server may not be able to connect to sites running on it.<br /> Error message: <em>" . $response->get_error_message() ."</em>" );
-				do_action( 'after_mu_upgrade', $response );
-				do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] );
-			}
+				echo '<li class="hidden" id="site-id-'. $details['blog_id'] .'" value="'. $details['blog_id'] .'"><span class="site_url">'. $siteurl .'</span> <strong class="status"></strong> <a href="#retry" class="button hidden">retry</a></li>' . "\n";
 		}
-		echo "</ul>";
-		?><p><?php _e("If your browser doesn't start loading the next page automatically click this link:"); ?> <a class="button" href="ms-upgrade-network.php?action=upgrade&amp;n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p>
+		echo '</ul>';
+		echo '<p id="alldone"></p>';
+		?>
 		<script type='text/javascript'>
-		<!--
-		function nextpage() {
-			location.href = "ms-upgrade-network.php?action=upgrade&n=<?php echo ($n + 5) ?>";
-		}
-		setTimeout( "nextpage()", 250 );
-		//-->
-		</script><?php
-	break;
+			jQuery(document).ready(function(){			
+				// Get all mu sites
+				var sites = jQuery('#updating li');
+
+				// Number of concurrent sites to perform the upgrade
+				var num = 5;
+				var offset = 0;
+
+				// number for successful, error and total sites
+				var e = 0;
+				var s = 0;
+				var t = <?php echo $total; ?>;
+
+				// array for queue
+				var sites_queue =[];
+				
+				// Run the upgrade script
+				wpms_get_sites_to_update( offset, num );
+				
+				function wpms_get_sites_to_update( offset, num ) {					
+					for ( var i = offset; i < num; i++ ) {
+						if ( undefined == sites[i] ) // sites[i] doesn't exists
+							break;
+						
+						if ( '-1' != jQuery.inArray(sites[i], sites_queue) ) // duplicate
+							break;
+						
+						// set sites[i] it into an array to avoid duplicates
+						sites_queue.push( sites[i] );
+						
+						var site_id  = sites[i].value;
+						var site_url = jQuery( '#site-id-' + site_id + ' .site_url' ).text();
+						
+						// Update the site status.
+						jQuery( '#site-id-' + site_id + ' .status' ).text('<?php echo esc_js( __( 'updating...' ) );?>');
+						
+						// update counting
+						var c = jQuery('span#update_site_count');
+						c.text( parseInt( c.text() ) + 1 );
+
+						// Show the site.
+						jQuery( '#site-id-' + site_id ).removeClass('hidden');
+			
+						// update the offset
+						offset = num;
+					
+						// Perform the upgrade
+						wpms_upgrade_site( site_id, site_url, offset );
+					};
+				}
+				
+				jQuery('#updating li a.button').click(function() {
+					// get site_id for retry
+				    var site_id = jQuery(this).parent().get(0).value;
+				    var site_url = jQuery( '#site-id-' + site_id + ' .site_url' ).text();
+				    
+					// update the site status
+					jQuery( '#site-id-' + site_id + ' .status' ).text('<?php echo esc_js( __( 'updating...' ) );?>');
+					
+					// remove retry button
+					jQuery('#site-id-' + site_id).find('.button').addClass('hidden');
+					
+					// update error count
+					e = e - 1;
+					
+					// next try
+				    wpms_upgrade_site( site_id, site_url, null );
+				})
+				
+				function wpms_upgrade_site( site_id, site_url, offset ) {
+					params = {
+						action: 'wpms-upgrade-site',
+						site_id: site_id,
+						site_url: site_url,
+					};
+
+					jQuery.post( ajaxurl, params, function(response) {
+						
+						if ( '1' == response ) {
+							// Update the site status
+							jQuery('#site-id-' + site_id).find('.status').html( '<?php echo esc_js( __( 'Successfully updated!' ) );?>' );
+							
+							// update successful count
+							s = s + 1;
+						} else {
+							// Update the site status
+							jQuery('#site-id-' + site_id).find('.status').html( '<?php echo esc_js( __( 'Update failed.' ) );?>' );
+							
+							// show retry button
+							jQuery('#site-id-' + site_id).find('.button').removeClass('hidden');
+
+							// update error count
+							e = e + 1;
+						};
+						// Update the status
+						if ( s == t )
+							jQuery('div#message p strong').html( '<?php echo esc_js( __( 'All sites successfully updated!' ) );?>');
+						else if ( (s + e) == t)
+							jQuery('div#message p strong').html( s + ' sites successfully updated and ' + e + ' updates failed!'); // translation ?
+
+						// next sites
+						if ( null != offset ) {
+							num = num + 5;
+							wpms_get_sites_to_update( offset, num );
+						}
+
+					}, 'json');
+				}
+			});
+		</script>
+		<?php	
+		break;
+		
 	case 'show':
 	default:
-		?><p><?php _e("You can update all the sites on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update."); ?></p>
-		<p><a class="button" href="ms-upgrade-network.php?action=upgrade"><?php _e("Update Network"); ?></a></p><?php
+		?><p><?php _e( 'You can update all the sites on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update.' ); ?></p>
+		<p><a class="button" href="ms-upgrade-network.php?action=upgrade"><?php _e( 'Update Network' ); ?></a></p><?php
 		do_action( 'wpmu_upgrade_page' );
 	break;
 }
-?>
-</div>
+echo '</div>';
 
-<?php include('admin-footer.php'); ?>
+include('admin-footer.php'); ?>
