diff --git a/rules_link.info b/rules_link.info
index 23fd1cb..1ccfb70 100644
--- a/rules_link.info
+++ b/rules_link.info
@@ -5,6 +5,7 @@ core = 7.x
 configure = admin/config/workflow/rules_links
 dependencies[] = rules
 dependencies[] = rules_admin
+dependencies[] = ctools
 files[] = rules_link.admin.inc
 files[] = rules_link.test
 ; Information added by drupal.org packaging script on 2011-12-19
diff --git a/rules_link.js b/rules_link.js
index 9fd8996..edea3a1 100644
--- a/rules_link.js
+++ b/rules_link.js
@@ -26,25 +26,7 @@
     $.ajax({
       type: 'GET',
       url: element.href,
-      dataType: 'json',
-      success: function (data) {
-        wrapper.removeClass('rules-link-waiting');
-        if (data.message.status !== undefined) {
-          $(element).replaceWith("<span>" + data.message.status +"</span>");
-        }
-        else {
-          $(element).remove();
-        }
-      },
-      error: function (xmlhttp) {
-        alert(Drupal.t('An HTTP error '+ xmlhttp.status +' occurred.\n'+ element.href));
-        wrapper.removeClass('rules-link-waiting');
-        message.text("Error while executing the rules link.");
-        message.show();
-        setTimeout(function(){
-          message.fadeOut();
-        }, 3000);
-      }
+      dataType: 'json'
     });
     return false;
   };
diff --git a/rules_link.module b/rules_link.module
index 1b280d2..d338efb 100644
--- a/rules_link.module
+++ b/rules_link.module
@@ -184,28 +184,30 @@ function rules_link_render($rules_link_name, $entity_id, $destination = NULL, $p
  */
 function rules_link_render_link($rules_link, $entity_id, $destination = NULL, $parameters = array()) {
   if (rules_link_check_visibility($rules_link, array_merge(array($entity_id), $parameters))) {
-    $path = $rules_link->path . '/' . $entity_id;
+    $path = $rules_link->path . '/nojs/' . $entity_id . '';
     if (count($parameters) > 0) {
       $path .= '/' . implode('/', $parameters);
     }
     $path .= $rules_link->settings['link_type'] == 'confirm' ? '' : '/' . rules_link_get_token($entity_id);
-
     $link = array(
       '#type' => 'link',
       '#title' => $rules_link->settings['text'],
       '#href' => $path,
-      '#attributes' => array('class' => array('rules-link')),
+      '#attributes' => array(
+        'class' => array('rules-link'),
+        'id' => 'rules-link-' . $rules_link->name . "-" . $entity_id,
+      ),
       '#prefix' => '<span class="rules-link-wrapper">',
       '#suffix' => '</span>'
     );
     if ($rules_link->settings['link_type'] == 'javascript') {
-      $link['#attributes']['class'][] = 'rules-link-js';
+      $link['#attributes']['class'][] = 'use-ajax';
       drupal_add_js(drupal_get_path('module', 'rules_link') . '/rules_link.js', 'file');
       drupal_add_css(drupal_get_path('module', 'rules_link') . '/rules_link.css', 'file');
     }
-    else {
-      $link['#options'] = array('query' => $destination);
-    }
+    $link['#options'] = array('query' => $destination);
     return $link;
   }
   return array();
@@ -260,6 +262,7 @@ function rules_link_get_paramters() {
   // Remove the first two arguments, since they are the rules link and the
   // entity id.
   array_shift($args);
+  array_shift($args);
   return $args;
 }
 
@@ -279,18 +282,25 @@ function rules_link_check_visibility($rules_link, $args) {
  * Triggers a rule set from a rules link.
  */
 function rules_link_trigger($rules_link, $entity_id) {
-  rules_link_invoke_component(rules_link_get_rules_set_name($rules_link), rules_link_get_paramters());
+  return rules_link_invoke_component(rules_link_get_rules_set_name($rules_link), rules_link_get_paramters());
 }
 
 /**
  * Menu callback for javascript links.
  */
-function rules_link_trigger_js($rules_link, $entity_id) {
-  rules_link_trigger($rules_link, $entity_id);
-  $json = array(
-    'message' => drupal_get_messages(),
-  );
-  drupal_json_output($json);
+function rules_link_trigger_js($rules_link, $entity_id, $js = false) {
+  $result = rules_link_trigger($rules_link, $entity_id);
+  if (!$js) {
+    drupal_goto();
+  }
+  
+  $commands = array();
+  $commands[] = ajax_command_before('#rules-link-' . $rules_link->name . "-" . $entity_id,theme('status_messages'));
+  
+  print ajax_render($commands);
 }
 
 /**
@@ -352,12 +362,12 @@ function rules_link_menu() {
   $item = array();
 
   foreach (rules_link_get_links() as $name => $link) {
-    $first_arg = (count(explode('/', $link->path)));
+    $first_arg = (count(explode('/', $link->path))) + 1;
     switch ($link->settings['link_type']) {
       case 'javascript':
-        $item[$link->path . '/%/%'] = array(
+        $item[$link->path . '/%ctools_js/%/%'] = array(
           'page callback' => 'rules_link_trigger_js',
-          'page arguments' => array($link, $first_arg),
+          'page arguments' => array($link, $first_arg, $first_arg - 1),
           'access arguments' => array($link, $first_arg, $first_arg + 1),
           'access callback' => 'rules_link_access_link',
           'type' => MENU_CALLBACK,
