Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 14046)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -1422,6 +1422,25 @@
 	update_post_meta( $link_id, '_menu_item_url', $link_url );
 
 	die( json_encode($link_id) );
+case 'wpms-upgrade-site':
+	$site_id = intval( $_POST['site_id'] );
+	$site_url = esc_url_raw( $_POST['site_url'] );
+
+	// die(json_encode( array($site_id, $site_url) )); // debug
+
+	// 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 = '-1';
+
+	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 14046)
+++ wp-admin/ms-upgrade-network.php	(working copy)
@@ -28,42 +28,96 @@
 $action = isset($_GET['action']) ? $_GET['action'] : 'show';
 
 switch ( $action ) {
-	case "upgrade":
-		$n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0;
-
-		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>";
+	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 );
+		
+		// Feedback
+		echo '<div id="message" class="updated">';
+		echo '<p><strong>Updating sites <span id="update_site_count">1</span> of '. count($blogs) .'</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></li>';
 			}
 		}
-		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;
+				
+				// 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++ ) {
+						console.log(  undefined == sites[i] );
+						
+						// console.log(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('updating...');
+
+						// 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 );
+					};
+				}
+				
+				function wpms_upgrade_site( site_id, site_url, offset ) {					
+					params = {
+						action: 'wpms-upgrade-site',
+						site_id: site_id,
+						site_url: site_url,
+					};
+					
+					wpms_get_sites_to_update( offset, num + num );
+					// return;
+					// wpms_get_sites_to_update( num );
+					
+					// save the link
+					/*
+					jQuery.post( ajaxurl, params, function(response) {
+						console.log(response);
+						
+						if ( '1' == response ) {
+							// Update the site status
+							jQuery('#site-id-' + site_id).find('.status').html( 'successfully updated!' );
+						} else {
+							// Update the site status
+							jQuery('#site-id-' + site_id).find('.status').html( 'update failed. <a href="#" class="button">retry</a>' );
+						};
+						
+						num = num + num;
+						wpms_get_sites_to_update( 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>
@@ -71,7 +125,6 @@
 		do_action( 'wpmu_upgrade_page' );
 	break;
 }
-?>
-</div>
+echo '</div>';
 
-<?php include('admin-footer.php'); ?>
+include('admin-footer.php'); ?>
\ No newline at end of file
