Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 16586)
+++ wp-includes/functions.php	(working copy)
@@ -2660,6 +2660,9 @@
 	if ( function_exists( 'apply_filters' ) ) {
 		$function = apply_filters( 'wp_die_handler', '_default_wp_die_handler');
 	}else {
+            if(defined('DOING_AJAX') && DOING_AJAX)
+                $function = '_ajax_wp_die_handler';            
+            else
 		$function = '_default_wp_die_handler';
 	}
 
@@ -2758,7 +2761,36 @@
 	die();
 }
 
+function _ajax_die_handler_filter() { 
+    return '_ajax_wp_die_handler'; 
+}
+
 /**
+ * Kill WordPress execution and send AJAX response with error message.
+ *
+ * This is AJAX-version of the default handler for wp_die
+ *
+ * @since 3.0.0
+ * @access private
+ *
+ * @param string $message Error message.
+ * @param string $title Error title.
+ * @param string|array $args Optional arguements to control behaviour.
+ */
+function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {    
+	$defaults = array( 'response' => 500 );
+	$r = wp_parse_args($args, $defaults);	      	
+        if ( !headers_sent() ) {
+		status_header( $r['response'] );
+        }
+        $resp   =   new WP_Ajax_Response( array(
+			'what' => 'autosave',
+			'id' => $message                        
+		) );          
+	$resp->send();        
+	die();
+}
+/**
  * Retrieve the WordPress home page URL.
  *
  * If the constant named 'WP_HOME' exists, then it willl be used and returned by
Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 16586)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -21,6 +21,9 @@
 
 require_once('./includes/admin.php');
 @header('Content-Type: text/html; charset=' . get_option('blog_charset'));
+
+add_filter('wp_die_handler','_ajax_die_handler_filter');
+
 send_nosniff_header();
 
 do_action('admin_init');
