Index: wp-admin/admin-header.php
===================================================================
--- wp-admin/admin-header.php	(revision 18974)
+++ wp-admin/admin-header.php	(working copy)
@@ -54,7 +54,7 @@
 		'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
 		'time':'<?php echo time() ?>'
 	},
-	ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
+	ajaxurl = '<?php echo relative_admin_url('admin-ajax.php'); ?>',
 	pagenow = '<?php echo $current_screen->id; ?>',
 	typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
 	adminpage = '<?php echo $admin_body_class; ?>',
Index: wp-admin/includes/image-edit.php
===================================================================
--- wp-admin/includes/image-edit.php	(revision 18974)
+++ wp-admin/includes/image-edit.php	(working copy)
@@ -67,7 +67,7 @@
 	<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo $meta['height']; ?>" />
 
 	<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
-	<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url('admin-ajax.php'); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
+	<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo relative_admin_url('admin-ajax.php'); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
 	</div>
 
 	<div class="imgedit-submit">
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 18974)
+++ wp-admin/includes/media.php	(working copy)
@@ -328,7 +328,7 @@
 //<![CDATA[
 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time(); ?>'};
-var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
+var ajaxurl = '<?php echo relative_admin_url('admin-ajax.php'); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
 isRtl = <?php echo (int) is_rtl(); ?>;
 //]]>
 </script>
Index: wp-admin/includes/template.php
===================================================================
--- wp-admin/includes/template.php	(revision 18974)
+++ wp-admin/includes/template.php	(working copy)
@@ -1369,7 +1369,7 @@
 		'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
 		'time':'<?php echo time() ?>'
 	},
-	ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
+	ajaxurl = '<?php echo relative_admin_url('admin-ajax.php'); ?>',
 	pagenow = '<?php echo $current_screen->id; ?>',
 	typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
 	adminpage = '<?php echo $admin_body_class; ?>',
Index: wp-admin/press-this.php
===================================================================
--- wp-admin/press-this.php	(revision 18974)
+++ wp-admin/press-this.php	(working copy)
@@ -295,7 +295,7 @@
 //<![CDATA[
 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
-var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
+var ajaxurl = '<?php echo relative_admin_url('admin-ajax.php'); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
 var photostorage = false;
 //]]>
 </script>
Index: wp-includes/class-wp-editor.php
===================================================================
--- wp-includes/class-wp-editor.php	(revision 18974)
+++ wp-includes/class-wp-editor.php	(working copy)
@@ -595,7 +595,7 @@
 		}
 
 		if ( !is_admin() )
-			echo 'var ajaxurl = "' . admin_url('admin-ajax.php') . '";';
+			echo 'var ajaxurl = "' . relative_admin_url('admin-ajax.php') . '";';
 ?>
 	</script>
 <?php
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 18974)
+++ wp-includes/link-template.php	(working copy)
@@ -1955,6 +1955,20 @@
 }
 
 /**
+ * Retrieve the relative url to the admin area for the current site.
+ *
+ * @package WordPress
+ * @since 3.4.0
+ *
+ * @param string $path Optional path relative to the admin url.
+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
+ * @return string Relative admin url link with optional path appended.
+*/
+function relative_admin_url( $path = '', $scheme = 'admin' ) {
+	return preg_replace( '#^http(s)?://[^/]*#', '', get_admin_url(null, $path, $scheme) );
+}
+
+/**
  * Retrieve the url to the admin area for a given site.
  *
  * @package WordPress
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 18974)
+++ wp-includes/media.php	(working copy)
@@ -1096,7 +1096,7 @@
 <script type="text/javascript">
 /* <![CDATA[ */
 	jQuery(document).ready(function($){
-		$.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post_ID ); ?>");
+		$.get("<?php echo relative_admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post_ID ); ?>");
 	});
 /* ]]> */
 </script>
