Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1129
diff -u -p -r1.1129 common.inc
--- includes/common.inc	18 Mar 2010 19:15:02 -0000	1.1129
+++ includes/common.inc	20 Mar 2010 19:06:01 -0000
@@ -3321,7 +3321,10 @@ function drupal_html_class($class) {
  *   The cleaned ID.
  */
 function drupal_html_id($id) {
-  $seen_ids = &drupal_static(__FUNCTION__, array());
+  // Prepopulate HTML ids for AJAX requests.
+  // @see ajax.js
+  $seen_ids = &drupal_static(__FUNCTION__, (!empty($_POST['ajax_html_ids']) ? $_POST['ajax_html_ids'] : array()));
+
   $id = strtr(drupal_strtolower($id), array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
 
   // As defined in http://www.w3.org/TR/html4/types.html#type-name, HTML IDs can
Index: misc/ajax.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/ajax.js,v
retrieving revision 1.12
diff -u -p -r1.12 ajax.js
--- misc/ajax.js	10 Mar 2010 15:14:38 -0000	1.12
+++ misc/ajax.js	20 Mar 2010 19:04:02 -0000
@@ -204,6 +204,12 @@ Drupal.ajax.prototype.beforeSubmit = fun
   // find the #ajax binding.
   form_values.push({ name: 'ajax_triggering_element', value: this.formPath });
 
+  // Prevent duplicate HTML ids in the returned markup.
+  // @see drupal_html_id()
+  $('[id]').each(function () {
+    form_values.push({ name: 'ajax_html_ids[' + this.id + ']', value: 1 });
+  });
+
   // Insert progressbar or throbber.
   if (this.progress.type == 'bar') {
     var progressBar = new Drupal.progressBar('ajax-progress-' + this.element.id, eval(this.progress.update_callback), this.progress.method, eval(this.progress.error_callback));
