function using ajax and return value problem

function using ajax and return value problem

I am stumped. First plug-in project and have hit a snag.

Declaring a function which utilizes the .ajax() call will not return the data retrieved during the 'success' function.

Here is the code if anyone could tell me what I am doing wrong... thanks in advance.

  1. (function($){
    $.rsaKey = function(proxy) {
      $.ajax({
       data: 'ssl-key=true',
       type: 'post',
       url: proxy,
       success: function(response) {
        return response;
       }
      });
     }
     $.fn.gibberish = function(options) {










  2.   var options = $.extend(defaults, options);
  3.   return this.each(function() {
  4.    var data = $.rsaKey(options.proxy);
  5.    alert(data);
  6.   });
  7.  });
  8. })(jQuery);