如何从插件返回一些值?
这是我的插件,
(function($){
    $.fn.extend({ 
        get_authentication: function(options) {
     var defaults = {
                file:           'json.php',
                location:       'xfolder/',
                callback:       function(data) {}
            }
            var options = $.extend(defaults, options);
            var o = options;
            var $this = this;
            var authentication = false; 
            $.get(http_root + o.file, function(data){
                // Send the data out from this plugin.
                if(data) {
                    options.callback(data);
                    authentication = true;
                    // alert(authentication); // --> get 'true'
                    return authentication; 
                }
                // Redirect if the date returns as 'expired'.
                if(data && data.error == 'expired') window.location = http_root + o.location;;
            },"json");
        }
    });
})(jQuery);
所以,如果我得到正确的 json 格式数据,我希望插件可以自动返回“true”。如果我想进入 json 数据,它也允许回调。
在dom准备好了,
var data = $.fn.get_authentication();
alert(data); // --> returns 'undefined'
可能吗?