diff --git uc_out_of_stock.js uc_out_of_stock.js
index afc4d48..589e56f 100644
--- uc_out_of_stock.js
+++ uc_out_of_stock.js
@@ -4,98 +4,91 @@ $(document).ready(function(){
   // Your code here
   attrid = 'edit-attributes';
 
-  function checkStock(form) {
-    var product = new Object();
-    var attributes = new Object();
-    var formid_data = new Array();
+  function checkStock(forms) {
+    var form_ids = new Array();
+    var node_ids = new Array();
+    var attr_ids = new Array();
+    $.each(forms, function(index, form) {
+      var product = new Object();
+      var attributes = new Object();
+      var formid_data = new Array();
 
-    product.nid = form.attr('id').match(/(?:uc-product-add-to-cart-form-|catalog-buy-it-now-form-)([0-9]+)/)[1];
-    attributes.found = new Object();
-    attributes.value = new Object();
+      var nid = form.attr('id').match(/(?:uc-product-add-to-cart-form-|catalog-buy-it-now-form-)([0-9]+)/)[1];
 
-    $(":input[@name*=attributes]:not(:text)", form).each(function(index){
-      id = $(this).attr('name').substring(11,$(this).attr('name').length-1);
-      if ($(this).is(':radio')) {
-        attributes.found['attr'+id] = 1;
-        if ($(this).is(':checked')) {
+      attributes.found = new Object();
+      attributes.value = new Object();
+
+      $(":input[@name*=attributes]:not(:text)", form).each(function(index){
+        id = $(this).attr('name').substring(11,$(this).attr('name').length-1);
+        if ($(this).is(':radio')) {
+          attributes.found['attr'+id] = 1;
+          if ($(this).is(':checked')) {
+            if ($(this).val()) {
+              attributes.value['attr'+id] = 1;
+              attr_ids.push(nid + ':' + id + ':' + $(this).val());
+            }
+          }
+        }
+        else {
+          attributes.found['attr'+id] = 1;
           if ($(this).val()) {
             attributes.value['attr'+id] = 1;
-            product['attr'+id] = $(this).val();
+            attr_ids.push(nid + ':' + id + ':' + $(this).val());
           }
         }
-      } else {
-      attributes.found['attr'+id] = 1;
-        if ($(this).val()) {
-          attributes.value['attr'+id] = 1;
-          product['attr'+id] = $(this).val();
-        }
-      }
-    });
+      });
 
-    // finding if attributes are found with no value
-    attributes.found.length = attributes.value.length = 0;
-    for (var i in attributes.found) {
-      if (i!='length') {
-        attributes.found.length++;
+      // finding if attributes are found with no value
+      attributes.found.length = attributes.value.length = 0;
+      for (var i in attributes.found) {
+        if (i!='length') {
+          attributes.found.length++;
+        }
       }
-    }
-    for (var i in attributes.value) {
-      if (i!='length') {
-        attributes.value.length++;
+      for (var i in attributes.value) {
+        if (i!='length') {
+          attributes.value.length++;
+        }
       }
-    }
-    if (attributes.found.length != attributes.value.length) {
-      // Put back the normal HTML of the add to cart form
-      $(".uc_out_of_stock_html", form).html('');
-      $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", form).show();
-      return;
-    }
-
-    $(".uc_out_of_stock_throbbing", form).addClass('uc_oos_throbbing');
-    $.post(Drupal.settings.basePath+'uc_out_of_stock/query', product, function (data, textStatus) {
-      // textStatus can be one of:
-      //   "timeout"
-      //   "error"
-      //   "notmodified"
-      //   "success"
-      //   "parsererror"
-      data = data.split('|');
-      stock = data[0];
-      if (stock == parseInt(stock) && stock <= 0 && data.length == 2) {
-        html = data[1];
-        $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", form).hide();
-        $(".uc_out_of_stock_html", form).html(html);
-      } else {
+      if (attributes.found.length != attributes.value.length) {
         // Put back the normal HTML of the add to cart form
         $(".uc_out_of_stock_html", form).html('');
         $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", form).show();
+        return;
       }
 
-      $(".uc_out_of_stock_throbbing", form).removeClass('uc_oos_throbbing');
+      $(".uc_out_of_stock_throbbing", form).addClass('uc_oos_throbbing');
+      form_ids.push(form.attr('id'));
+      node_ids.push(nid);
     });
-  }
-
-  $("form[@id*=uc-product-add-to-cart-form]").each(function(index) {
-    var eachForm;
-    $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", $(this)).before('<div class="uc_out_of_stock_throbbing">&nbsp;&nbsp;&nbsp;&nbsp;</div> ');
-    $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", $(this)).after('<div class="uc_out_of_stock_html"></div');
 
-    eachForm = $(this);
-    checkStock(eachForm);
+    var post = { 'form_ids[]': form_ids, 'node_ids[]': node_ids, 'attr_ids[]': attr_ids }
+    $.post(Drupal.settings.basePath+'uc_out_of_stock/query', post, function (data, textStatus) {
+      $.each(data, function(form_id, stock_level) {
+        var form = $('#' + form_id);
+        if (stock_level != null && parseInt(stock_level) <= 0) {
+          $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", form).hide();
+          $(".uc_out_of_stock_html", form).html(Drupal.settings.uc_out_of_stock.msg);
+        }
+        else {
+          // Put back the normal HTML of the add to cart form
+          $(".uc_out_of_stock_html", form).html('');
+          $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", form).show();
+        }
+        $(".uc_out_of_stock_throbbing", form).removeClass('uc_oos_throbbing');
+      });
+    }, 'json');
+  }
 
+  var forms = new Array();
+  $("form[id*=uc-product-add-to-cart-form], form[id*=uc-catalog-buy-it-now-form]").each(function(index) {
+    forms.push($(this));
+    $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", $(this)).before('<div class="uc_out_of_stock_throbbing">&nbsp;&nbsp;&nbsp;&nbsp;</div>');
+    $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", $(this)).after('<div class="uc_out_of_stock_html"></div>');
+    var form = $(this);
     $(":input[@name*=attributes]:not(:text)", $(this)).change(function(){
-      checkStock(eachForm);
+      checkStock([form]);
     });
   });
-
-  $("form[@id*=uc-catalog-buy-it-now-form]").each(function(index) {
-    var eachForm;
-    $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", $(this)).before('<div class="uc_out_of_stock_throbbing">&nbsp;&nbsp;&nbsp;&nbsp;</div> ');
-    $("input:submit.node-add-to-cart,input:submit.list-add-to-cart", $(this)).after('<div class="uc_out_of_stock_html"></div');
-
-    eachForm = $(this);
-    checkStock(eachForm);
-
-    // This form has no possible attributes
-  });
-});
\ No newline at end of file
+  checkStock(forms);
+});
diff --git uc_out_of_stock.module uc_out_of_stock.module
index 5fa1f59..e5cd011 100644
--- uc_out_of_stock.module
+++ uc_out_of_stock.module
@@ -11,11 +11,19 @@ define ('UC_OUT_OF_STOCK_DEFAULT_HTML', t('<span style="color: red;">Out of stoc
  * Implementation of hook_form_alter()
  */
 function uc_out_of_stock_form_alter(&$form, $form_state, $form_id) {
+  static $added_setting;
   $forms = array('uc_product_add_to_cart_form', 'uc_catalog_buy_it_now_form');
   foreach ($forms as $id) {
     if ( substr($form_id, 0, strlen($id)) == $id ) {
       drupal_add_js(drupal_get_path('module', 'uc_out_of_stock') . '/uc_out_of_stock.js');
       drupal_add_css(drupal_get_path('module', 'uc_out_of_stock') . '/uc_out_of_stock.css');
+      if (!isset($added_setting)) {
+        drupal_add_js(array(
+          'uc_out_of_stock' => array(
+            'msg' => check_markup(variable_get('uc_out_of_stock_text', UC_OUT_OF_STOCK_DEFAULT_HTML), variable_get('uc_out_of_stock_format', FILTER_FORMAT_DEFAULT), FALSE),
+        )), 'setting');
+        $added_setting = TRUE;
+      }
       $form['#validate'][] = 'uc_out_of_stock_validate_form_addtocart';
     }
   }
@@ -27,7 +35,6 @@ function uc_out_of_stock_form_alter(&$form, $form_state, $form_id) {
   if ($form_id == 'uc_cart_checkout_form' || $form_id == 'uc_cart_checkout_review_form') {
     $form['#validate'][] = 'uc_out_of_stock_validate_form_checkout';
   }
-
 }
 
 /**
@@ -109,29 +116,50 @@ function uc_out_of_stock_getstockinfo($nid, $attrs) {
   return $stockinfo;
 }
 
+/**
+ * Called via AJAX to determine stock for one or more products
+ * Expects the following variables:
+ * $_POST['form_ids'] => An array of form ids
+ * $_POST['node_ids'] => A corresponding array of node ids
+ * $_POST['attr_ids'] => An array of nid:attrib_id:value based on the attribute selected
+ *
+ * Returns an array of array(form ids => stock value or NULL)
+ */
 function uc_out_of_stock_query() {
-  $response = array();
-  $attrs = array();
+  if (count($_POST['form_ids']) != count($_POST['node_ids'])) {
+    print 'Invalid data posted.';
+  }
 
-  $nid = $_POST['nid'];
-  foreach ( $_POST as $key => $value ) {
-    if ( substr($key, 0, 4) == 'attr' ) {
-      $attrs[substr($key, 4)] = $value;
+  $return = array_combine($_POST['form_ids'], array_fill(0, count($_POST['form_ids']), NULL));
+  // If no attributes given we can do one query to fetch everything
+  if (empty($_POST['attr_ids'])) {
+    $result = db_query('SELECT ups.stock, up.nid
+                        FROM {uc_products} up
+                        LEFT JOIN {uc_product_stock} ups ON ups.sku = up.model
+                        WHERE up.nid IN(' . db_placeholders($_POST['node_ids'], 'int') . ')
+                        AND ups.active = 1', $_POST['node_ids']);
+    while ($product = db_fetch_object($result)) {
+      $key = array_search($product->nid, $_POST['node_ids']);
+      $return[$_POST['form_ids'][$key]] = $product->stock;
     }
   }
+  else {
+    $attribs = array();
+    foreach ($_POST['attr_ids'] as $value) {
+      list($nid, $attr_id, $attr_val) = explode(':', $value);
+      $attribs[$nid][$attr_id] = $attr_val;
+    }
 
-  $stockinfo = uc_out_of_stock_getstockinfo($nid, $attrs);
-  if ($stockinfo) {
-    $response['stock'] = $stockinfo['stock'];
-    if ( $response['stock'] <= 0 ) {
-      $response['html'] = check_markup(variable_get('uc_out_of_stock_text', UC_OUT_OF_STOCK_DEFAULT_HTML), variable_get('uc_out_of_stock_format', FILTER_FORMAT_DEFAULT), FALSE);
+    foreach ($_POST['node_ids'] as $key => $nid) {
+      $stockinfo = uc_out_of_stock_getstockinfo($nid, (array) $attribs[$nid]);
+      if ($stockinfo) {
+        $return[$_POST['form_ids'][$key]] = $stockinfo['stock'];
+      }
     }
   }
-  
-  // if there is some response, print it
-  if (count($response)){
-    print implode('|', $response);
-  }
+
+  print drupal_json($return);
+  exit;
 }
 
 function uc_out_of_stock_settings() {
@@ -331,4 +359,4 @@ function uc_out_of_stock_add_to_cart($nid, $qty, $data) {
 }
  *
  * /
- */
\ No newline at end of file
+ */
