diff --git a/includes/common.inc b/includes/common.inc
index 34fa9b9..2b58e82 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3963,6 +3963,9 @@ function drupal_html_id($id) {
       // requested id. $_POST['ajax_html_ids'] contains the ids as they were
       // returned by this function, potentially with the appended counter, so
       // we parse that to reconstruct the $seen_ids array.
+      if (is_string($_POST['ajax_html_ids'])) {
+        $_POST['ajax_html_ids'] = array($_POST['ajax_html_ids']);
+      }
       if (isset($_POST['ajax_html_ids'][0]) && strpos($_POST['ajax_html_ids'][0], ',') === FALSE) {
         $ajax_html_ids = $_POST['ajax_html_ids'];
       }
diff --git a/misc/ajax.js b/misc/ajax.js
index bb4a6e1..caeacdb 100644
--- a/misc/ajax.js
+++ b/misc/ajax.js
@@ -320,10 +320,11 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) {
 
   // Prevent duplicate HTML ids in the returned markup.
   // @see drupal_html_id()
-  options.data['ajax_html_ids[]'] = [];
+  options.data['ajax_html_ids'] = [];
   $('[id]').each(function () {
-    options.data['ajax_html_ids[]'].push(this.id);
+    options.data['ajax_html_ids'].push(this.id);
   });
+  options.data['ajax_html_ids'] = options.data['ajax_html_ids'].join(',');
 
   // Allow Drupal to return new JavaScript and CSS files to load without
   // returning the ones already loaded.
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index bf1e9c3..9ac8241 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -2196,9 +2196,13 @@ class DrupalWebTestCase extends DrupalTestCase {
         $extra_post .= '&' . urlencode($key) . '=' . urlencode($value);
       }
     }
+    $html_ids = array();
     foreach ($this->xpath('//*[@id]') as $element) {
       $id = (string) $element['id'];
-      $extra_post .= '&' . urlencode('ajax_html_ids[]') . '=' . urlencode($id);
+      $html_ids[urlencode($id)] = urlencode($id);
+    }
+    if (!empty($html_ids)) {
+      $extra_post .= '&' . urlencode('ajax_html_ids') . '=' . implode(',', $html_ids);
     }
     if (isset($drupal_settings['ajaxPageState'])) {
       $extra_post .= '&' . urlencode('ajax_page_state[theme]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme']);
